1
0
mirror of https://github.com/django/django.git synced 2025-10-28 08:06:09 +00:00

Add AlterField and RenameField operations

This commit is contained in:
Andrew Godwin
2013-06-20 15:12:59 +01:00
parent 6f667999e1
commit 80bdf68d6b
4 changed files with 129 additions and 3 deletions

View File

@@ -93,10 +93,17 @@ class ModelState(object):
def clone(self):
"Returns an exact copy of this ModelState"
# We deep-clone the fields using deconstruction
fields = []
for name, field in self.fields:
_, path, args, kwargs = field.deconstruct()
field_class = import_by_path(path)
fields.append((name, field_class(*args, **kwargs)))
# Now make a copy
return self.__class__(
app_label = self.app_label,
name = self.name,
fields = list(self.fields),
fields = fields,
options = dict(self.options),
bases = self.bases,
)