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
2. 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.
--
Ticket URL: <https://code.djangoproject.com/ticket/33385>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
* component: Migrations => contrib.auth
Comment:
Duplicate of #29843.
--
Ticket URL: <https://code.djangoproject.com/ticket/33385#comment:1>