rename_permissions_after_model_rename
Updates Django permission codenames and names in the database after a model has been renamed during a migration. This function performs database I/O to modify permission records and raises a RuntimeError if it detects naming conflicts that cannot be resolved automatically.
def rename_permissions_after_model_rename(
app_config: AppConfig,
verbosity: int = 2,
plan: list = None,
using: str = DEFAULT_DB_ALIAS,
apps: Apps = global_apps,
stdout: file-like object = sys.stdout
)
Updates Django auth permission codenames and display names in the database after a model has been renamed via migrations. This function ensures that permission strings remain synchronized with the new model name to prevent broken access control logic.
Parameters
| Name | Type | Description |
|---|---|---|
| app_config | AppConfig | The configuration object for the Django application currently undergoing migration. |
| verbosity | int = 2 | Controls the amount of notification messages printed to stdout; higher values provide more detailed logs of renamed permissions. |
| plan | list = None | A list of (migration, backward) tuples representing the migration plan used to identify RenameModel operations. |
| using | str = DEFAULT_DB_ALIAS | The database alias on which the permission updates should be performed. |
| apps | Apps = global_apps | The registry containing the models for the current application state. |
| stdout | file-like object = sys.stdout | The output stream where status messages and warnings are written. |