Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BenAtWide/eef5acfc42219fd6846050c4c2b5c948 to your computer and use it in GitHub Desktop.
Save BenAtWide/eef5acfc42219fd6846050c4c2b5c948 to your computer and use it in GitHub Desktop.
Django: Programmatically add permissions to groups
content_type = ContentType.objects.get(app_label='', model='')
#get all permssions for this model
perms = Permission.objects.filter(content_type=content_type)
group = Group.objects.get(name='')
for p in perms:
group.permissions.add(perms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment