def create_document_editor_group():
 (group, group_created) = Group.objects.get_or_create(name='editor')
 if group_created:
  actions = ('add', 'change', 'delete', 'view', 'restore')
  perms = [Permission.objects.get(codename=('%s_document' % action)) for action in actions]
  group.permissions = perms
  group.save()
 return group

def create_document_editor_group ( ) : ( group , group_created ) = Group . objects . get_or_create ( name = 'editor' ) if group_created : actions = ( 'add' , 'change' , 'delete' , 'view' , 'restore' ) perms = [ Permission . objects . get ( codename = ( '%s_document' % action ) ) for action in actions ] group . permissions = perms group . save ( ) return group
get or create a group that can edit documents .