Previous Page Next Page

Widget Objects

The Django forms package uses Widget objects to represent HTML elements. Widget objects are assigned to Form Field objects and provide two services. The first service is to render the Field object as an HTML element. The second service is to extract the data from the HTML elements during a GET/POST request. Table B.1 lists the Widget objects along with their HTML equivalent code.

Table B.1. Django Widget Objects and Their HTML Equivalents
WidgetHTML Equivalent
TextInput<input type='text' ...
PasswordInput<input type='password' ...
HiddenInput<input type='hidden' ...
MultipleHiddenInputMultiple <input type='hidden' ... instances
FileInput<input type='file' ...
Textarea<textarea>...</textarea>
CheckboxInput<input type='checkbox' ...
Select<select><option ...
NullBooleanSelectSelect widget with options Unknown, Yes, and No
SelectMultiple<select multiple='multiple'><option ...
RadioSelect<ul><li><input type='radio' ...
CheckboxSelectMultiple<ul><li><input type='checkbox' ...
MultiWidgetWrapper around multiple other widgets
SplitDateTimeWidgetWrapper around two TextInput widgets: one for the Date and one for the Time


Previous Page Next Page