diff options
| author | Tim Graham <timograham@gmail.com> | 2015-07-16 08:00:29 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-07-21 09:19:40 -0400 |
| commit | b60375d4bbb848af7950379e2f35a1a65f7a2591 (patch) | |
| tree | eca0b028a0a8d3da5d7f348e1f65186146bf5eb7 /docs/ref | |
| parent | 04e69598de75550a9227bfac353ff5606b6cbe43 (diff) | |
Fixed #25129 -- Made model instance defaults work with migrations (refs #24919).
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/fields.txt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 6d3176512c..7243276305 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -220,6 +220,10 @@ 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. +For fields like :class:`ForeignKey` that map to model instances, defaults +should be the value of the field they reference (``pk`` unless +:attr:`~ForeignKey.to_field` is set) instead of model instances. + The default value is used when new model instances are created and a value isn't provided for the field. When the field is a primary key, the default is also used when the field is set to ``None``. |
