Getting “Permission denied” page in the admin, while user has permission

后端 未结 2 1954
没有蜡笔的小新
没有蜡笔的小新 2021-01-22 08:53

I\'ve got some issue with user permissions in Django. I added some permissions for the Magasin model as shown below:

add_magasin=Permission.objects.         


        
相关标签:
2条回答
  • 2021-01-22 09:33

    The first argument of User.has_perm() have to be a string in <app label>.<permission codename> format. In you're code you're passing Permission instance as first argument, which get's evaluated to <app_label> | <content_type> | <name>, so has_perm will always return False.

    Instead use user.has_perm("<yourapp>.delete_magasin")

    0 讨论(0)
  • 2021-01-22 09:40

    It seems it has to do with file permissions, not Django user permissions.

    0 讨论(0)
提交回复
热议问题