diff options
| author | Zowie Beha <113861530+1zzowiebeha@users.noreply.github.com> | 2023-12-30 16:54:34 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-01-02 05:24:24 +0100 |
| commit | 031bc4710138e36445322488a8074c1b9e835702 (patch) | |
| tree | b4aeb1b18b29f13ad0a67c064d0af856dd4c69a9 /docs | |
| parent | c69dbc7c1068a0a059ed77120c30b4cebbcf0e4b (diff) | |
[5.0.x] Fixed #35072 -- Corrected Field.choices description in models topic.
Backport of 8fcd7b01eec85a509762dd8dbb3a27b7ab521e94 from main
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/db/models.txt | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt index cc6c1f5298..b419185bbc 100644 --- a/docs/topics/db/models.txt +++ b/docs/topics/db/models.txt @@ -157,9 +157,12 @@ ones: <Field.blank>`, the field will be required. :attr:`~Field.choices` - A :term:`sequence` of 2-tuples to use as choices for this field. If this - is given, the default form widget will be a select box instead of the - standard text field and will limit choices to the choices given. + A :term:`sequence` of 2-value tuples, a :term:`mapping`, an + :ref:`enumeration type <field-choices-enum-types>`, or a callable (that + expects no arguments and returns any of the previous formats), to use as + choices for this field. If this is given, the default form widget will be a + select box instead of the standard text field and will limit choices to the + choices given. A choices list looks like this:: @@ -216,6 +219,10 @@ ones: Further examples are available in the :ref:`model field reference <field-choices>`. + .. versionchanged:: 5.0 + + Support for mappings and callables was added. + :attr:`~Field.default` 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 |
