Refs #28192 -- Fixed documentation of ChoiceField choices requirement
Thanks Tim Graham for noticing the issue.
This commit is contained in:
parent
8e752d8437
commit
54caca2d34
|
@ -408,7 +408,7 @@ For each field, we describe the default widget used if you don't specify
|
||||||
The ``invalid_choice`` error message may contain ``%(value)s``, which will be
|
The ``invalid_choice`` error message may contain ``%(value)s``, which will be
|
||||||
replaced with the selected choice.
|
replaced with the selected choice.
|
||||||
|
|
||||||
Takes one extra required argument:
|
Takes one extra argument:
|
||||||
|
|
||||||
.. attribute:: choices
|
.. attribute:: choices
|
||||||
|
|
||||||
|
@ -418,6 +418,7 @@ For each field, we describe the default widget used if you don't specify
|
||||||
model field. See the :ref:`model field reference documentation on
|
model field. See the :ref:`model field reference documentation on
|
||||||
choices <field-choices>` for more details. If the argument is a
|
choices <field-choices>` for more details. If the argument is a
|
||||||
callable, it is evaluated each time the field's form is initialized.
|
callable, it is evaluated each time the field's form is initialized.
|
||||||
|
Defaults to an emtpy list.
|
||||||
|
|
||||||
``TypedChoiceField``
|
``TypedChoiceField``
|
||||||
--------------------
|
--------------------
|
||||||
|
|
|
@ -52,6 +52,10 @@ class ChoiceFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
|
||||||
with self.assertRaisesMessage(ValidationError, msg):
|
with self.assertRaisesMessage(ValidationError, msg):
|
||||||
f.clean('6')
|
f.clean('6')
|
||||||
|
|
||||||
|
def test_choicefield_choices_default(self):
|
||||||
|
f = ChoiceField()
|
||||||
|
self.assertEqual(f.choices, [])
|
||||||
|
|
||||||
def test_choicefield_callable(self):
|
def test_choicefield_callable(self):
|
||||||
def choices():
|
def choices():
|
||||||
return [('J', 'John'), ('P', 'Paul')]
|
return [('J', 'John'), ('P', 'Paul')]
|
||||||
|
|
Loading…
Reference in New Issue