Django widgets handle the rendering of the HTML for form fields
A widget is Django’s representation of a HTML input element. The widget handles the rendering of the HTML, and the extraction of data from a GET/POST dictionary that corresponds to the widget. -- https://docs.djangoproject.com/en/dev/ref/forms/widgets/
Django includes a number of built in widgets, including TextInput
, RadioSelect
and CheckboxInput
. It is easy to change the way a form field is displayed by declaring the widget when you define your Django form.
For example, if you have a form ChoiceField
, where the user can choose from a list of options, your choice of widget determines whether this is rendered as a dropdown menu, or a list of radio buttons.
If custom behavior is required, Django's built in widgets can be subclassed and extended.