How to add a permission to a user/group during a django migration?
问题 I would like to execute the following migration: # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.contrib.auth.models import Permission from django.db import migrations from django.conf import settings from django.contrib.auth.models import Group, User def add_api_group(apps, schema_editor): Group.objects.create(name=settings.API_USER_GROUP) # get_or_create returns a tuple, not a Group group = Group.objects.get(name=settings.API_USER_GROUP) permissions = Permission