mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #30868 -- Prevented unnecessary AlterField when renaming a referenced pk.
Regression introduced by dcdd219ee1, refs #25817.
Thanks Carlos E. C. Leite for the report and Mariusz for the bisect.
This commit is contained in:
committed by
Mariusz Felisiak
parent
d232fd76a8
commit
2839659b42
@@ -927,6 +927,10 @@ class MigrationAutodetector:
|
||||
if remote_field_name:
|
||||
to_field_rename_key = rename_key + (remote_field_name,)
|
||||
if to_field_rename_key in self.renamed_fields:
|
||||
# Repoint both model and field name because to_field
|
||||
# inclusion in ForeignKey.deconstruct() is based on
|
||||
# both.
|
||||
new_field.remote_field.model = old_field.remote_field.model
|
||||
new_field.remote_field.field_name = old_field.remote_field.field_name
|
||||
# Handle ForeignObjects which can have multiple from_fields/to_fields.
|
||||
from_fields = getattr(new_field, 'from_fields', None)
|
||||
|
||||
Reference in New Issue
Block a user