diff options
| author | maheen8q <mah.een8q@gmai.com> | 2026-07-05 00:22:53 +0500 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2026-07-29 15:53:58 +0200 |
| commit | e1feeee45ea8bcd4325554c9b94fcd75fcd8dbdc (patch) | |
| tree | b33ff52f7c690517d11fe7f7dd785ab1897fccce | |
| parent | a959c2596f8a1d1ef9f321b8b227a399e86409e2 (diff) | |
Fixed #37194 -- Removed redundant choice widget documentation.
The removed section primarily provided usage examples and recommendations
rather than documenting the widget API. The interaction between a choice
field and its widget is already documented in the Select.choices reference.
| -rw-r--r-- | docs/ref/forms/widgets.txt | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index 25f6079a0a..edb6d8c783 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -79,39 +79,6 @@ widget on the field. In the following example, the See the :ref:`built-in widgets` for more information about which widgets are available and which arguments they accept. -Widgets inheriting from the ``Select`` widget -============================================= - -Widgets inheriting from the :class:`Select` widget deal with choices. They -present the user with a list of options to choose from. The different widgets -present this choice differently; the :class:`Select` widget itself uses a -``<select>`` HTML list representation, while :class:`RadioSelect` uses radio -buttons. - -:class:`Select` widgets are used by default on :class:`ChoiceField` fields. The -choices displayed on the widget are inherited from the :class:`ChoiceField` and -changing :attr:`ChoiceField.choices` will update :attr:`Select.choices`. For -example: - -.. code-block:: pycon - - >>> from django import forms - >>> CHOICES = {"1": "First", "2": "Second"} - >>> choice_field = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES) - >>> choice_field.choices - [('1', 'First'), ('2', 'Second')] - >>> choice_field.widget.choices - [('1', 'First'), ('2', 'Second')] - >>> choice_field.widget.choices = [] - >>> choice_field.choices = [("1", "First and only")] - >>> choice_field.widget.choices - [('1', 'First and only')] - -Widgets which offer a :attr:`~Select.choices` attribute can however be used -with fields which are not based on choice -- such as a :class:`CharField` -- -but it is recommended to use a :class:`ChoiceField`-based field when the -choices are inherent to the model and not just the representational widget. - Customizing widget instances ============================ |
