summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlokik Vijay <alokik.roe@gmail.com>2022-04-30 21:29:51 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-05-03 15:27:00 +0200
commit256db5c0482c7cef1e1754a8a853d58f6c6299e9 (patch)
tree7087bdef8d05444158ad3ea6d71b6746ce3fb5f4
parent5db5c33baa7ddc0a5670e91ce2ac8024aad5d290 (diff)
downloaddjango-256db5c0482c7cef1e1754a8a853d58f6c6299e9.tar.gz
[4.0.x] Fixed #33658 -- Doc'd ModelChoiceField.blank attribute.
Thanks Mariusz Felisiak for reviewing. Backport of df22566748faa7bd16a9616617875e8370cbe4ee from main
-rw-r--r--docs/ref/forms/fields.txt17
1 files changed, 13 insertions, 4 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index a88f2fb8ab..016ccc3922 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -1235,7 +1235,7 @@ generating choices. See :ref:`iterating-relationship-choices` for details.
are derived and which is used to validate the user's selection. It's
evaluated when the form is rendered.
- ``ModelChoiceField`` also takes two optional arguments:
+ ``ModelChoiceField`` also takes several optional arguments:
.. attribute:: empty_label
@@ -1251,9 +1251,11 @@ generating choices. See :ref:`iterating-relationship-choices` for details.
# No empty label
field2 = forms.ModelChoiceField(queryset=..., empty_label=None)
- Note that if a ``ModelChoiceField`` is required and has a default
- initial value, no empty choice is created (regardless of the value
- of ``empty_label``).
+ Note that no empty choice is created (regardless of the value of
+ ``empty_label``) if a ``ModelChoiceField`` is required and has a
+ default initial value, or a ``widget`` is set to
+ :class:`~django.forms.RadioSelect` and the
+ :attr:`~ModelChoiceField.blank` argument is ``False``.
.. attribute:: to_field_name
@@ -1291,6 +1293,13 @@ generating choices. See :ref:`iterating-relationship-choices` for details.
...
</select>
+ .. attribute:: blank
+
+ When using the :class:`~django.forms.RadioSelect` widget, this optional
+ boolean argument determines whether an empty choice is created. By
+ default, ``blank`` is ``False``, in which case no empty choice is
+ created.
+
``ModelChoiceField`` also has the attribute:
.. attribute:: iterator