Nips Nips - 1 year ago 83
Python Question

How to get user permissions?

I want to retrieve all permission for user as list of premission id's but:


give me list of permission names. How to do it?

Answer Source

The key is get the permission objects like this:

permissions = Permission.objects.filter(user=user)

and there you can access the id property like this:


If you want the list (id, permission_name) do the following:

perm_tuple = [(, for x in Permission.objects.filter(user=user)]

Hope it helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download