[Django] #33385: Unexpected behavior regarding custom permissions creation

4 views
Skip to first unread message

Django

unread,
Dec 26, 2021, 2:47:47 AM12/26/21
to django-...@googlegroups.com
#33385: Unexpected behavior regarding custom permissions creation
-----------------------------------------+------------------------
Reporter: Ramez Issac | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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
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.

Django

unread,
Dec 26, 2021, 2:48:46 PM12/26/21
to django-...@googlegroups.com
#33385: Unexpected behavior regarding custom permissions creation
-------------------------------+--------------------------------------

Reporter: Ramez Issac | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.auth | Version: 2.2
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => duplicate
* component: Migrations => contrib.auth


Comment:

Duplicate of #29843.

--
Ticket URL: <https://code.djangoproject.com/ticket/33385#comment:1>

Reply all
Reply to author
Forward
0 new messages