Hi,--Since the permissions are not yet created when the migrations are run, it is not possible to have a data migration that creates a group and assigns permissions.Based on this ticket: https://code.djangoproject.com/ticket/23422, I understand there will not be a fix. Do you recommend to keep using an initial fixture to create a group?ThanksMichael
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/cce3b138-6524-417c-b05e-cd3c25742e3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
create_permissions(my_app_config)
my_app_config.get_models()
from django.apps import apps
apps.get_app_config('my_app').models_module
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/ca2a503a-bdbc-4280-b401-02a2c94cfaa6%40googlegroups.com.
from django.apps.registry import apps as apps_alt
from django.contrib.auth.management import create_permissions
for app_config in apps_alt.get_app_configs():
create_permissions(app_config)
def fix_perms(*app_labels):
def wrapped(apps, schema_editor):
from django.apps.registry import apps
from django.contrib.contenttypes.management import update_contenttypes
from django.contrib.auth.management import create_permissions
for app in app_labels:
app_conf = apps.get_app_config(app)
update_contenttypes(app_conf, app_conf.get_models())
create_permissions(app_conf, interactive=False)
return wrapped
class Migration(migrations.Migration):
operations = [
migrations.RunPython(fix_perms("books")),
migrations.RunPython(add_some_group_permissions_on_books
),
]