Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. bee-keeper created this gist Mar 29, 2014.
    8 changes: 8 additions & 0 deletions Django: Programmatically add permissions to groups
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    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)