summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-07-25 09:35:25 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-07-25 09:35:53 -0700
commit919d10e619872b56a4d6bc91ccd031b90775a437 (patch)
treeab17df742cf43aa3744a83c7947cef106f8ceff5 /django
parent2bacc9f3b70e45b172675452b7dd32900fbb8a8b (diff)
[1.7.x] Fixed #23093: soft application detection for swapped models
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/executor.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py
index ecd9d0fdf2..10cbfc80f0 100644
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -1,6 +1,7 @@
from __future__ import unicode_literals
from django.db import migrations
+from django.apps.registry import apps as global_apps
from .loader import MigrationLoader
from .recorder import MigrationRecorder
@@ -136,6 +137,10 @@ class MigrationExecutor(object):
for operation in migration.operations:
if isinstance(operation, migrations.CreateModel):
model = apps.get_model(migration.app_label, operation.name)
+ if model._meta.swapped:
+ # We have to fetch the model to test with from the
+ # main app cache, as it's not a direct dependency.
+ model = global_apps.get_model(model._meta.swapped)
if model._meta.db_table not in self.connection.introspection.get_table_list(self.connection.cursor()):
return False
found_create_migration = True