Reputation: 248
I want to list all the permissions that my user has be it a custom permission or default permission
what I have tried till now
But none of them returned any permissions though the user was a superuser, staff and active
Any lead and help will be great
Upvotes: 0
Views: 36
Reputation: 476659
An admin user normally has no permissions assigned to them, the .has_perm(…)
[Django-doc] will always return True
, or as the documentation says:
Returns
True
if the user has the specified permission, where perm is in the format"<app label>.<permission codename>"
. (see documentation on permissions). If the user is inactive, this method will always returnFalse
. For an active superuser, this method will always returnTrue
.
So the admin user is not assigned all permissions (this would also be "error-prone" since later new permissions can pop up, and it would thus require extra logic to add these to the superusers that already exist.
Upvotes: 1