1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.7.x] Fixed #23503 -- Fixed renaming of model with self-referential m2m field.

Backport of 463952d940 from master
This commit is contained in:
Sergey Fedoseev
2014-09-17 11:34:10 +06:00
committed by Tim Graham
parent 58d7b84d53
commit 991ec655b6
3 changed files with 25 additions and 0 deletions

View File

@@ -734,6 +734,12 @@ class BaseDatabaseSchemaEditor(object):
old_field.rel.through._meta.get_field_by_name(old_field.m2m_reverse_field_name())[0],
new_field.rel.through._meta.get_field_by_name(new_field.m2m_reverse_field_name())[0],
)
self.alter_field(
new_field.rel.through,
# for self-referential models we need to alter field from the other end too
old_field.rel.through._meta.get_field_by_name(old_field.m2m_field_name())[0],
new_field.rel.through._meta.get_field_by_name(new_field.m2m_field_name())[0],
)
def _create_index_name(self, model, column_names, suffix=""):
"""