summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMarkus Holtermann <info@markusholtermann.eu>2014-08-20 16:15:23 +0200
committerTim Graham <timograham@gmail.com>2014-08-20 16:04:21 -0400
commit144cff3f516f7c718cbe4bd3165e18781c09042a (patch)
tree5b24533e8d3e35d26f1b0c454d54dccff406d251 /django
parent53ff0969822ac2248a89ccb6fef1088212dc800d (diff)
Fixed #23322 -- Use resolved swappable model for dependency resolution during makemigrations
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/autodetector.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index e67c8aa902..4a837fbba1 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -237,9 +237,17 @@ class MigrationAutodetector(object):
deps_satisfied = True
operation_dependencies = set()
for dep in operation._auto_deps:
+ is_swappable_dep = False
if dep[0] == "__setting__":
- operation_dependencies.add((dep[0], dep[1]))
- elif dep[0] != app_label:
+ # We need to temporarily resolve the swappable dependency to prevent
+ # circular references. While keeping the dependency checks on the
+ # resolved model we still add the swappable dependencies.
+ # See #23322
+ resolved_app_label, resolved_object_name = getattr(settings, dep[1]).split('.')
+ original_dep = dep
+ dep = (resolved_app_label, resolved_object_name.lower(), dep[2], dep[3])
+ is_swappable_dep = True
+ if dep[0] != app_label and dep[0] != "__setting__":
# External app dependency. See if it's not yet
# satisfied.
for other_operation in self.generated_operations.get(dep[0], []):
@@ -249,7 +257,9 @@ class MigrationAutodetector(object):
if not deps_satisfied:
break
else:
- if self.migrations.get(dep[0], None):
+ if is_swappable_dep:
+ operation_dependencies.add((original_dep[0], original_dep[1]))
+ elif dep[0] in self.migrations:
operation_dependencies.add((dep[0], self.migrations[dep[0]][-1].name))
else:
# If we can't find the other app, we add a first/last dependency,