mirror of
https://github.com/django/django.git
synced 2025-11-03 13:23:19 +00:00
Refs #24354 -- Prevented repointing of relations on superclasses when migrating a subclass's name change
The issue was hidden on 1.8+ until #24573 due to a bug inside the model
reloading process.
Forwardport of patch from ae87ad005f
This commit is contained in:
parent
1a1f16d67d
commit
e4b7daec11
1 changed files with 4 additions and 0 deletions
|
|
@ -169,6 +169,10 @@ class RenameModel(Operation):
|
||||||
state.remove_model(app_label, self.old_name_lower)
|
state.remove_model(app_label, self.old_name_lower)
|
||||||
# Repoint the FKs and M2Ms pointing to us
|
# Repoint the FKs and M2Ms pointing to us
|
||||||
for related_object in all_related_objects:
|
for related_object in all_related_objects:
|
||||||
|
if related_object.model is not model:
|
||||||
|
# The model being renamed does not participate in this relation
|
||||||
|
# directly. Rather, a superclass does.
|
||||||
|
continue
|
||||||
# Use the new related key for self referential related objects.
|
# Use the new related key for self referential related objects.
|
||||||
if related_object.related_model == model:
|
if related_object.related_model == model:
|
||||||
related_key = (app_label, self.new_name_lower)
|
related_key = (app_label, self.new_name_lower)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue