summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2017-06-03 09:50:14 +0200
committerClaude Paroz <claude@2xlibre.net>2017-06-03 16:19:09 +0200
commit81c3967e554716dbb5c86ebc390fd07389c39c2e (patch)
treefc83c19bd95371a6beb3aa88e029eacfa05960b9
parent9a3bcaf46aba223789f42df8bc08348694d9f16f (diff)
[1.11.x] Refs #28192 -- Fixed documentation of ChoiceField choices requirement
Thanks Tim Graham for noticing the issue. Backport of 54caca2d34c7cb6807da0a82bcec7b3a679ac104 from master.
-rw-r--r--docs/ref/forms/fields.txt3
-rw-r--r--tests/forms_tests/field_tests/test_choicefield.py4
2 files changed, 6 insertions, 1 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index e2cfb59df2..8e419c7b5b 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -409,7 +409,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
replaced with the selected choice.
- Takes one extra required argument:
+ Takes one extra argument:
.. attribute:: choices
@@ -419,6 +419,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
choices <field-choices>` for more details. If the argument is a
callable, it is evaluated each time the field's form is initialized.
+ Defaults to an emtpy list.
``TypedChoiceField``
--------------------
diff --git a/tests/forms_tests/field_tests/test_choicefield.py b/tests/forms_tests/field_tests/test_choicefield.py
index 1d8fe5a3cf..ad773615ae 100644
--- a/tests/forms_tests/field_tests/test_choicefield.py
+++ b/tests/forms_tests/field_tests/test_choicefield.py
@@ -55,6 +55,10 @@ class ChoiceFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
with self.assertRaisesMessage(ValidationError, msg):
f.clean('6')
+ def test_choicefield_choices_default(self):
+ f = ChoiceField()
+ self.assertEqual(f.choices, [])
+
def test_choicefield_callable(self):
def choices():
return [('J', 'John'), ('P', 'Paul')]