diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 21934cf..a99522c 100644
a
|
b
|
The default cannot be a mutable object (model instance, list, set, etc.), as a
|
209 | 209 | reference to the same instance of that object would be used as the default |
210 | 210 | value in all new model instances. Instead, wrap the desired default in a |
211 | 211 | callable. For example, if you had a custom ``JSONField`` and wanted to specify |
212 | | a dictionary as the default, use a ``lambda`` as follows:: |
| 212 | a dictionary as the default, use a function as follows:: |
213 | 213 | |
214 | | contact_info = JSONField("ContactInfo", default=lambda:{"email": "to1@example.com"}) |
| 214 | def contact_default(): |
| 215 | return {"email": "to1@example.com"} |
| 216 | |
| 217 | contact_info = JSONField("ContactInfo", default=contact_default) |
| 218 | |
| 219 | Note that ``lambda``\s cannot be used for field options like ``default`` |
| 220 | because they cannot be :ref:`serialized by migrations <migration-serializing>`. |
| 221 | See that documentation for other caveats. |
215 | 222 | |
216 | 223 | ``editable`` |
217 | 224 | ------------ |
… |
… |
define the details of how the relation works.
|
1101 | 1108 | with the Python ``datetime`` module to limit selections by date range. For |
1102 | 1109 | example:: |
1103 | 1110 | |
1104 | | limit_choices_to = lambda: {'pub_date__lte': datetime.date.utcnow()} |
| 1111 | def limit_pub_date_choices(): |
| 1112 | return {'pub_date__lte': datetime.date.utcnow()} |
| 1113 | |
| 1114 | limit_choices_to = limit_pub_date_choices |
1105 | 1115 | |
1106 | 1116 | If ``limit_choices_to`` is or returns a :class:`Q object |
1107 | 1117 | <django.db.models.Q>`, which is useful for :ref:`complex queries |