Last active
November 28, 2016 08:11
-
-
Save zhu327/6d3a79b9377964fdbb0f611f06a4e19b to your computer and use it in GitHub Desktop.
get user all permissions Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import Permission, User | |
def get_user_permissions(user): | |
if user.is_superuser: | |
return Permission.objects.all() | |
return Permission.objects.filter(Q(group__user=user)|Q(user=user)).distinct() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment