diff options
| author | Artyom Kotovskiy <mrartem1927@gmail.com> | 2025-04-20 18:17:47 -0400 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-27 07:45:21 -0500 |
| commit | a040f555069971192220122555f187530d679d53 (patch) | |
| tree | ab59214658c5ccb71de7df63dd6da0237b705a00 /docs | |
| parent | 187a789f99ecbc708de517c6b54d480b68ba59fe (diff) | |
Fixed #27489 -- Renamed permissions upon model renaming in migrations.
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/6.1.txt | 3 | ||||
| -rw-r--r-- | docs/topics/auth/default.txt | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/docs/releases/6.1.txt b/docs/releases/6.1.txt index ef6ae1d424..d10225dfdf 100644 --- a/docs/releases/6.1.txt +++ b/docs/releases/6.1.txt @@ -123,6 +123,9 @@ Minor features * The default iteration count for the PBKDF2 password hasher is increased from 1,200,000 to 1,500,000. +* :attr:`.Permission.name` and :attr:`.Permission.codename` values are now + renamed when renaming models via a migration. + :mod:`django.contrib.contenttypes` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt index f9d216e1df..77888febb3 100644 --- a/docs/topics/auth/default.txt +++ b/docs/topics/auth/default.txt @@ -219,6 +219,18 @@ permissions for new models each time you run :djadmin:`manage.py migrate <migrate>` (the function that creates permissions is connected to the :data:`~django.db.models.signals.post_migrate` signal). +When a model is renamed in an installed application, Django automatically +updates the associated default permissions to match the new model name when +you run :djadmin:`manage.py migrate <migrate>`. + +If a permission with the new codename already exists +(for example, due to a leftover permission from a previous migration), +Django raises an error with next steps. + +.. versionchanged:: 6.1 + + Updating permissions when models are renamed was added. + Assuming you have an application with an :attr:`~django.db.models.Options.app_label` ``foo`` and a model named ``Bar``, to test for basic permissions you should use: |
