summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/models/fields/__init__.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 1fa230e1c2..6b2dc2ad21 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -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):