From f1a22feaa877e4ff655db7014557112274419898 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 31 Dec 2014 13:21:32 +0800 Subject: [PATCH] [1.7.x] Renamed variables to avoid name collision with import of django.db.models. Backport of 013c2d8d02e679c969255d9b11214d020dd34418 from master --- django/db/migrations/autodetector.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index b323182df9..e14a6cd634 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -457,11 +457,11 @@ class MigrationAutodetector(object): old_keys = set(self.old_model_keys).union(self.old_unmanaged_keys) added_models = set(self.new_model_keys) - old_keys added_unmanaged_models = set(self.new_unmanaged_keys) - old_keys - models = chain( + all_added_models = chain( sorted(added_models, key=self.swappable_first_key, reverse=True), sorted(added_unmanaged_models, key=self.swappable_first_key, reverse=True) ) - for app_label, model_name in models: + for app_label, model_name in all_added_models: model_state = self.to_state.models[app_label, model_name] model_opts = self.new_apps.get_model(app_label, model_name)._meta # Gather related fields @@ -634,8 +634,8 @@ class MigrationAutodetector(object): new_keys = set(self.new_model_keys).union(self.new_unmanaged_keys) deleted_models = set(self.old_model_keys) - new_keys deleted_unmanaged_models = set(self.old_unmanaged_keys) - new_keys - models = chain(sorted(deleted_models), sorted(deleted_unmanaged_models)) - for app_label, model_name in models: + all_deleted_models = chain(sorted(deleted_models), sorted(deleted_unmanaged_models)) + for app_label, model_name in all_deleted_models: model_state = self.from_state.models[app_label, model_name] model = self.old_apps.get_model(app_label, model_name) if not model._meta.managed: