Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bee-keeper/9857973 to your computer and use it in GitHub Desktop.
Save bee-keeper/9857973 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)
@IlRatto
Copy link

IlRatto commented May 22, 2023

bellissimo, utile!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment