Opened 3 years ago

Closed 3 years ago

#33385 closed Uncategorized (duplicate)

Unexpected behavior regarding custom permissions creation

Reported by: Ramez Issac Owned by: nobody
Component: contrib.auth Version: 2.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello wonderful Django community ,

Brief of the issue:
Custom permissions are created at the very end of a manage.py migrate.
Not after its addition in the same migration migrations.AlterModelOptions, Nor after the its specific migration is applied .

Outcome:
One can not assign custom permissions in a data migration.

Use Case:
I added some custom permissions on a model and i want to assign some of those new permissions to users based on some criteria.
I made this assignment in the same migration. It failed because the new permissions were not found.
Ok, i can understand that...
So, i made another data migration and put the assignment there, also this fails because permission is not found.

What i have to do then is

  1. python manage.py migrate my_app migration_with_meta_change_adding_perms

Then

  1. python manage.py migrate my_app migration_with_the_run_python_assign_permissions

And i have to execute it explicitly like shown above or else it will fail... i don't think this is the expected behavior.

Change History (1)

comment:1 by Tim Graham, 3 years ago

Component: Migrationscontrib.auth
Resolution: duplicate
Status: newclosed

Duplicate of #29843.

Note: See TracTickets for help on using tickets.
Back to Top