summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorVictor Oliveira da Silva <victor_o_silva@hotmail.com>2016-08-13 22:56:21 -0300
committerTim Graham <timograham@gmail.com>2016-08-15 10:46:02 -0400
commitdad8ec49c4284cd13a252d1d76f4152484264742 (patch)
tree08d5e42e47b44139a6e0419bc5ba198d0571efe5 /docs
parenteea74edc7068a9c75f0f7b09ae59bfdcacc35195 (diff)
[1.10.x] Made cosmetic edits to Field.default docs.
Backport of d7804662f8d929a3d363ef7a73e6cad9243acd96 from master
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/fields.txt14
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index eb93bbab6e..4b962f30c0 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -207,20 +207,20 @@ support tablespaces for indexes, this option is ignored.
The default value for the field. This can be a value or a callable object. If
callable it will be called every time a new object is created.
-The default cannot be a mutable object (model instance, list, set, etc.), as a
-reference to the same instance of that object would be used as the default
+The default can't be a mutable object (model instance, ``list``, ``set``, etc.),
+as a reference to the same instance of that object would be used as the default
value in all new model instances. Instead, wrap the desired default in a
-callable. For example, if you had a custom ``JSONField`` and wanted to specify
-a dictionary as the default, use a function as follows::
+callable. For example, if you want to specify a default ``dict`` for
+:class:`~django.contrib.postgres.fields.JSONField`, use a function::
def contact_default():
return {"email": "to1@example.com"}
contact_info = JSONField("ContactInfo", default=contact_default)
-Note that ``lambda``\s cannot be used for field options like ``default``
-because they cannot be :ref:`serialized by migrations <migration-serializing>`.
-See that documentation for other caveats.
+``lambda``\s can't be used for field options like ``default`` because they
+can't be :ref:`serialized by migrations <migration-serializing>`. See that
+documentation for other caveats.
For fields like :class:`ForeignKey` that map to model instances, defaults
should be the value of the field they reference (``pk`` unless