Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fix error in ModelState.clone() not copying deep enough

  • Loading branch information...
commit e6ba63def327441a167a901108b10e8dccfe9ab1 1 parent e6f7f45
@andrewgodwin andrewgodwin authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 django/db/migrations/
8 django/db/migrations/
@@ -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 @@ def clone(self):
return self.__class__(
app_label = self.app_label,
name =,
- fields = self.fields,
- options = self.options,
+ fields = list(self.fields),
+ options = dict(self.options),
bases = self.bases,
Please sign in to comment.
Something went wrong with that request. Please try again.