[Answered ]-Django user doesn't inherit its groups permissions

1👍

Use User.get_all_permissions() to get all permissions that the user has including permissions inherited from groups or use User.get_group_permissions to get all permissions that a user has from their groups

jack_permissions = jack.get_all_permissions()

0👍

I presume your many-to-one relation chain is like the following:

User > Group > Permission

And you want to get all permissions related to a particular user. If so, you can use double-underscore (__) notation to get the through relationship.

Does this get you what you want?

jack = User.objects.get(username="jack")
jack_permissions = Permission.objects.filter(group__users=jack)
👤0sVoid

Leave a comment