[Django] #37361: Permission renames do not apply to a chain of RenameModel operations

8 views
Skip to first unread message

Django

unread,
Sep 19, 2026, 5:15:36 PM (7 days ago) Sep 19
to django-...@googlegroups.com
#37361: Permission renames do not apply to a chain of RenameModel operations
-----------------------------+-------------------------------------------
Reporter: Jacob Walls | Type: Bug
Status: new | Component: contrib.auth
Version: 6.1 | Severity: Release blocker
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+-------------------------------------------
#27489 implemented renaming permissions as part of `RenameModel` migration
operations, but did not support a chain of multiple operations.

For a chain of renames A -> B -> C, the database is queried for
permissions on A, and then for permissions on B, but because all planned
renames are applied to the database in a second loop, the query for
permissions on B in the first loop finds nothing, so no second permission
rename is done in the second loop.

To reproduce:

1. Define Class A
2. `makemigrations`
3. `migrate` (this creates permissions)
4. Rename A -> B
5. `makemigrations` (answer "Y" to the rename prompt)
6. Rename B -> C
7. `makemigrations` (answer "Y" to the rename prompt)
8. `migrate -v2` (this renames permissions)

Expected: permissions in database end with "C"
Actual:
{{{
Renamed permission(s): myapp.add_a → add_b
Renamed permission(s): myapp.change_a → change_b
Renamed permission(s): myapp.delete_a → delete_b
Renamed permission(s): myapp.view_a → view_b
Adding permission 'Permission object (49)'
Adding permission 'Permission object (50)'
Adding permission 'Permission object (51)'
Adding permission 'Permission object (52)'
}}}

9. `migrate myapp zero`

{{{#!py
RuntimeError: 4 permission rename conflict(s) detected.
}}}

Bug in a040f555069971192220122555f187530d679d53.
--
Ticket URL: <https://code.djangoproject.com/ticket/37361>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 19, 2026, 7:31:18 PM (7 days ago) Sep 19
to django-...@googlegroups.com
#37361: Permission renames do not apply to a chain of RenameModel operations
---------------------------------+--------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: contrib.auth | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by Md. Saikat Islam):

I was able to reproduce it on Django `6.2.dev20260902172522`. I’ll take
this ticket once it’s marked as accepted. Looking forward to someone
marking it as accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/37361#comment:1>

Django

unread,
Sep 20, 2026, 2:14:39 AM (6 days ago) Sep 20
to django-...@googlegroups.com
#37361: Permission renames do not apply to a chain of RenameModel operations
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Md.
| Saikat Islam
Type: Bug | Status: assigned
Component: contrib.auth | Version: 6.1
Severity: Release blocker | Resolution:
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 Md. Saikat Islam):

* owner: (none) => Md. Saikat Islam
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37361#comment:2>

Django

unread,
Sep 22, 2026, 1:38:24 PM (4 days ago) Sep 22
to django-...@googlegroups.com
#37361: Permission renames do not apply to a chain of RenameModel operations
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Md.
| Saikat Islam
Type: Bug | Status: assigned
Component: contrib.auth | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Md. Saikat Islam):

* has_patch: 0 => 1
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/37361#comment:3>

Django

unread,
Sep 22, 2026, 1:40:57 PM (4 days ago) Sep 22
to django-...@googlegroups.com
#37361: Permission renames do not apply to a chain of RenameModel operations
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Md.
| Saikat Islam
Type: Bug | Status: assigned
Component: contrib.auth | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Md. Saikat Islam):

Looking forward to get reviews:
https://github.com/django/django/pull/22018
--
Ticket URL: <https://code.djangoproject.com/ticket/37361#comment:4>
Reply all
Reply to author
Forward
0 new messages