summaryrefslogtreecommitdiff
path: root/docs/howto
diff options
context:
space:
mode:
Diffstat (limited to 'docs/howto')
-rw-r--r--docs/howto/custom-model-fields.txt20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt
index 2dedf05a11..c4621c8500 100644
--- a/docs/howto/custom-model-fields.txt
+++ b/docs/howto/custom-model-fields.txt
@@ -314,6 +314,26 @@ reconstructing the field::
new_instance = MyField(*args, **kwargs)
self.assertEqual(my_field_instance.some_attribute, new_instance.some_attribute)
+.. _custom-field-non_db_attrs:
+
+Field attributes not affecting database column definition
+---------------------------------------------------------
+
+.. versionadded:: 4.1
+
+You can override ``Field.non_db_attrs`` to customize attributes of a field that
+don't affect a column definition. It's used during model migrations to detect
+no-op ``AlterField`` operations.
+
+For example::
+
+ class CommaSepField(models.Field):
+
+ @property
+ def non_db_attrs(self):
+ return super().non_db_attrs + ("separator",)
+
+
Changing a custom field's base class
------------------------------------