1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00

Add clone() method to Field to get clean copies of it.

This commit is contained in:
Andrew Godwin 2013-12-04 13:55:45 +00:00
parent ab587fa51a
commit df800b1609

View File

@ -240,6 +240,14 @@ class Field(object):
keywords,
)
def clone(self):
"""
Uses deconstruct() to clone a new copy of this Field.
Will not preserve any class attachments/attribute names.
"""
name, path, args, kwargs = self.deconstruct()
return self.__class__(*args, **kwargs)
def __eq__(self, other):
# Needed for @total_ordering
if isinstance(other, Field):