summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-03-25 18:30:29 -0400
committerTim Graham <timograham@gmail.com>2014-03-25 18:30:58 -0400
commit42336c84a0daedfd8242333622eefe202e32398e (patch)
treeb60843d02fee1983d2f9696ed4fb3ac7c05062a3 /django
parent378359de1c927e8b323b6b9fa2c4d2d2606a613f (diff)
Fixed #22331 -- Made MigrationAutodetector ignore unmanaged models.
This commit reverts 69d4b1c and tackle the issue from a different angle. Models remain present in the project state, but are now ignored by the autodetector.
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/autodetector.py21
-rw-r--r--django/db/migrations/state.py5
2 files changed, 13 insertions, 13 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index cbd08cc31d..e0631f8c82 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -51,16 +51,17 @@ class MigrationAutodetector(object):
new_apps = self.to_state.render()
# Prepare lists of old/new model keys that we care about
# (i.e. ignoring proxy ones)
- old_model_keys = [
- (al, mn)
- for al, mn in self.from_state.models.keys()
- if not old_apps.get_model(al, mn)._meta.proxy
- ]
- new_model_keys = [
- (al, mn)
- for al, mn in self.to_state.models.keys()
- if not new_apps.get_model(al, mn)._meta.proxy
- ]
+ old_model_keys = []
+ for al, mn in self.from_state.models.keys():
+ model = old_apps.get_model(al, mn)
+ if not model._meta.proxy and model._meta.managed:
+ old_model_keys.append((al, mn))
+
+ new_model_keys = []
+ for al, mn in self.to_state.models.keys():
+ model = new_apps.get_model(al, mn)
+ if not model._meta.proxy and model._meta.managed:
+ new_model_keys.append((al, mn))
def _rel_agnostic_fields_def(fields):
"""
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py
index 01019ff980..ab2bd8e6d8 100644
--- a/django/db/migrations/state.py
+++ b/django/db/migrations/state.py
@@ -58,9 +58,8 @@ class ProjectState(object):
"Takes in an Apps and returns a ProjectState matching it"
app_models = {}
for model in apps.get_models():
- if model._meta.managed:
- model_state = ModelState.from_model(model)
- app_models[(model_state.app_label, model_state.name.lower())] = model_state
+ model_state = ModelState.from_model(model)
+ app_models[(model_state.app_label, model_state.name.lower())] = model_state
return cls(app_models)
def __eq__(self, other):