summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2016-07-12 18:45:17 -0700
committerTim Graham <timograham@gmail.com>2016-07-12 21:45:17 -0400
commitb84ecaa736fd5e33bd5d95ac70e288db976a53ff (patch)
treec12ebf0632f495be5ec8dde9bb9224820a5bc50b /django
parent81963b37a92ef583b9f725f1a78dd2ca97c1ab95 (diff)
Fixed #26088 -- Made autodector detect changing proxy model to MTI.
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/autodetector.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index ae88a90465..c863dcaead 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -612,6 +612,20 @@ class MigrationAutodetector(object):
]
)
+ # Fix relationships if the model changed from a proxy model to a
+ # concrete model.
+ if (app_label, model_name) in self.old_proxy_keys:
+ for related_object in model_opts.related_objects:
+ self.add_operation(
+ related_object.related_model._meta.app_label,
+ operations.AlterField(
+ model_name=related_object.related_model._meta.object_name,
+ name=related_object.field.name,
+ field=related_object.field,
+ ),
+ dependencies=[(app_label, model_name, None, True)],
+ )
+
def generate_created_proxies(self):
"""
Makes CreateModel statements for proxy models.