summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-05-30 18:21:32 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-05-30 18:24:10 +0100
commite6ba63def327441a167a901108b10e8dccfe9ab1 (patch)
tree67d1ba2daf826108f170f40f0796896bc4c6a7f7
parente6f7f4533c183800c2a9ac526d8ee8887e96ac5d (diff)
Fix error in ModelState.clone() not copying deep enough
-rw-r--r--django/db/migrations/state.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py
index d189e8709e..b6618041f2 100644
--- a/django/db/migrations/state.py
+++ b/django/db/migrations/state.py
@@ -47,6 +47,10 @@ class ModelState(object):
Represents a Django Model. We don't use the actual Model class
as it's not designed to have its options changed - instead, we
mutate this one and then render it into a Model as required.
+
+ Note that while you are allowed to mutate .fields, you are not allowed
+ to mutate the Field instances inside there themselves - you must instead
+ assign new ones, as these are not detached during a clone.
"""
def __init__(self, app_label, name, fields, options=None, bases=None):
@@ -92,8 +96,8 @@ class ModelState(object):
return self.__class__(
app_label = self.app_label,
name = self.name,
- fields = self.fields,
- options = self.options,
+ fields = list(self.fields),
+ options = dict(self.options),
bases = self.bases,
)