mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #13181 -- Added support for callable choices to forms.ChoiceField
Thanks vanschelven and expleo for the initial patch.
This commit is contained in:
parent
e0685368c6
commit
74e1980cf9
4 changed files with 50 additions and 5 deletions
|
@ -387,10 +387,16 @@ For each field, we describe the default widget used if you don't specify
|
|||
|
||||
.. attribute:: choices
|
||||
|
||||
An iterable (e.g., a list or tuple) of 2-tuples to use as choices for this
|
||||
field. This argument accepts the same formats as the ``choices`` argument
|
||||
to a model field. See the :ref:`model field reference documentation on
|
||||
choices <field-choices>` for more details.
|
||||
Either an iterable (e.g., a list or tuple) of 2-tuples to use as
|
||||
choices for this field, or a callable that returns such an iterable.
|
||||
This argument accepts the same formats as the ``choices`` argument to a
|
||||
model field. See the :ref:`model field reference documentation on
|
||||
choices <field-choices>` for more details. If the argument is a
|
||||
callable, it is evaluated each time the field's form is initialized.
|
||||
|
||||
.. versionchanged:: 1.8
|
||||
|
||||
The ability to pass a callable to ``choices`` was added.
|
||||
|
||||
``TypedChoiceField``
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue