Thank you, Luis-José Torres!
On the basis of your code I added the following to my migrations:
def fix_perms(*app_labels):
def wrapped(apps, schema_editor):
from django.apps.registry import apps
from django.contrib.contenttypes.management import
update_contenttypes
fr
Hi,
This worked for me:
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)
On Tuesday, December 30, 2014 at 11:01:11 PM UTC-6, Adam Venturella wrote:
Hi Adam,
Migrations build a fake app registry containing fake app configs for each state
of the models.
They implement a small subset of features of the real app configs.
See
https://github.com/django/django/blob/5e32605/django/db/migrations/state.py#L119-L131
That’s why my_app_config.models_
Attempting this approach, calling :
create_permissions(my_app_config)
from within my migration fails to create the permissions. It looks like
*create_permissions
*checks for *models_module* on the provided app config. However, when my
migration runs, my *models_module* is *None. *
So is there
On 10/15/2014 06:52 AM, Michael wrote:
> Also, ContentType.objects.get_for_model does not work ('Manager' object
> has no attribute 'get_for_model').
Not sure, but it might work to instead call
`django.contrib.auth.management.create_permissions(...)` in the
migration? You'll need to get hold of th
Also, ContentType.objects.get_for_model does not work ('Manager' object has
no attribute 'get_for_model').
Le mercredi 15 octobre 2014 07:43:03 UTC-5, Michael a écrit :
>
> I do not want to create a permission, I want to assign to a group some of
> the default permissions django creates: add,
I do not want to create a permission, I want to assign to a group some of
the default permissions django creates: add, change and delete (
https://docs.djangoproject.com/en/dev/topics/auth/default/#default-permissions)
Obviously, the permissions are not created yet when I run my first python
ma
As the ticket suggests, you can call the function to create permissions
yourself in the data migration, and then you can assign them as normal.
There's no need to use fixtures (in fact, migrations are better without
fixtures, as there's no easy way to load them).
Andrew
On Tue, Oct 14, 2014 at 6:
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