Skip to content

Instantly share code, notes, and snippets.

@zhu327
Last active November 28, 2016 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhu327/6d3a79b9377964fdbb0f611f06a4e19b to your computer and use it in GitHub Desktop.
Save zhu327/6d3a79b9377964fdbb0f611f06a4e19b to your computer and use it in GitHub Desktop.
get user all permissions Django
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