Ticket #18478: 18478.diff

File 18478.diff, 898 bytes (added by Tim Graham, 12 years ago)
  • docs/ref/models/fields.txt

    diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
    index 275c696..5dbe269 100644
    a b support tablespaces for indexes, this option is ignored.  
    195195The default value for the field. This can be a value or a callable object. If
    196196callable it will be called every time a new object is created.
    197197
     198The default cannot be a mutable object (model instance, list, set, etc.), as a
     199reference to the same instance of that object would be used as the default
     200value for that field in all new model instances. Instead, wrap the desired
     201default in a callable.  For example, if you had a custom ``JSONField`` and
     202wanted to specify a dictionary as the default, use a ``lambda`` as follows::
     203
     204    contact_info = JSONField("ContactInfo", default=lambda:{"email": "to1@example.com"})
     205
    198206``editable``
    199207------------
    200208
Back to Top