summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@sixmedia.com>2013-09-01 04:18:44 +0700
committerTim Graham <timograham@gmail.com>2013-09-04 14:05:59 -0400
commit34d52fd32ed6192daa37e3fc1303cc5661130bad (patch)
treeb572ddc83fb4625084bef8c59c4b94fc3a0ac784
parent533d1ab334219d1c0d7791f94d71df771ef8ce76 (diff)
Fixed #21010 -- Changed ModelState to only copy _meta.local_fields.
-rw-r--r--django/db/migrations/state.py2
-rw-r--r--tests/migrations/test_state.py19
2 files changed, 20 insertions, 1 deletions
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py
index 8f0078d731..f4e0325472 100644
--- a/django/db/migrations/state.py
+++ b/django/db/migrations/state.py
@@ -70,7 +70,7 @@ class ModelState(object):
"""
# Deconstruct the fields
fields = []
- for field in model._meta.fields:
+ for field in model._meta.local_fields:
name, path, args, kwargs = field.deconstruct()
field_class = import_by_path(path)
fields.append((name, field_class(*args, **kwargs)))
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index e5b3fbfa08..1a903cb4f2 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -75,3 +75,22 @@ class StateTests(TestCase):
new_app_cache = project_state.render()
self.assertEqual(new_app_cache.get_model("migrations", "Tag")._meta.get_field_by_name("name")[0].max_length, 100)
self.assertEqual(new_app_cache.get_model("migrations", "Tag")._meta.get_field_by_name("hidden")[0].null, False)
+
+ def test_render_multiple_inheritance(self):
+ # Use a custom app cache to avoid polluting the global one.
+ new_app_cache = BaseAppCache()
+
+ class Book(models.Model):
+ title = models.CharField(max_length=1000)
+
+ class Meta:
+ app_label = "migrations"
+ app_cache = new_app_cache
+
+ class Novel(Book):
+ class Meta:
+ app_label = "migrations"
+ app_cache = new_app_cache
+
+ yet_another_app_cache = BaseAppCache()
+ ModelState.from_model(Novel).render(yet_another_app_cache)