Forked from bee-keeper/Django: Programmatically add permissions to groups
Created
March 29, 2018 13:38
-
-
Save BenAtWide/eef5acfc42219fd6846050c4c2b5c948 to your computer and use it in GitHub Desktop.
Django: Programmatically add permissions to groups
This file contains hidden or 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
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