0

Hi i am having trouble with Django User object.

I have created a group named 'Admin' and this group have the following permission 'can_change_name','can_update_name'.

A user 'falcon' belong to group 'Admin' i did this by performing the following query

user.groups.add(Group.objects.get(name='Admin))

When i perform the following query i am getting False instead of True.

user.has_perm('can_change_name') 

The above query give me False, i have a doubt why i am getting False even after adding the user into the appropriate group.

skid
  • 958
  • 4
  • 13
  • 29
  • 1
    Permissions are for a specific model, not general. It needs to be something like "my_model:can_change_name". – Daniel Roseman Mar 14 '19 at 19:15
  • You very likely got the permission name wrong. To check for the exact name you need to use, [see here](https://stackoverflow.com/questions/54441985/django-user-does-not-inherit-permission-from-group/54447175#answer-54447175). – Endre Both Mar 14 '19 at 19:23
  • @DanielRoseman Yes you are right that one works for me – skid Mar 14 '19 at 19:29

0 Answers0