summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-06-15 12:06:48 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-06-15 12:06:48 -0700
commitf717ef083aac2e839a86de1bac02b95e5fd1a4b1 (patch)
tree35d35392b751b5efbcde943508ee2cae3eaf5ecf /django
parent24afb1d7a746da131212d050404bbe8837cf6f1d (diff)
Fixed #22833: Autodetector not doing through mapping correctly
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/autodetector.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index 38371d2556..1be3df96f7 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -127,7 +127,11 @@ class MigrationAutodetector(object):
new_model_state = self.to_state.models[app_label, model_name]
self.old_field_keys.update((app_label, model_name, x) for x, y in old_model_state.fields)
self.new_field_keys.update((app_label, model_name, x) for x, y in new_model_state.fields)
- # Through model stuff
+
+ # Through model map generation
+ for app_label, model_name in sorted(self.old_model_keys):
+ old_model_name = self.renamed_models.get((app_label, model_name), model_name)
+ old_model_state = self.from_state.models[app_label, old_model_name]
for field_name, field in old_model_state.fields:
old_field = self.old_apps.get_model(app_label, old_model_name)._meta.get_field_by_name(field_name)[0]
if hasattr(old_field, "rel") and hasattr(old_field.rel, "through") and not old_field.rel.through._meta.auto_created: