I will answer your question exactly since I found this question from Google. I will show what I am doing in Django 1.9 with groups, and then show how to do it for the user.
from django.contrib.auth.models import Group, Permission group, __ = Group.objects.get_or_create (name = 'my_group')
permissions = Permission.objects.all() for p in permissions: group.permissions.add(p) group.save()
It is very easy to adapt to the user:
from django.contrib.auth.models import Permission permissions = Permission.objects.all() for p in permissions: youruser.user_permissions.add(p) youruser.save()
I prefer the group because you can add permissions in the future and you can just add permissions to the group instead of reusing all users.
std''OrgnlDave
source share