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.
Widget | HTML Equivalent |
---|---|
TextInput | <input type='text' ... |
PasswordInput | <input type='password' ... |
HiddenInput | <input type='hidden' ... |
MultipleHiddenInput | Multiple <input type='hidden' ... instances |
FileInput | <input type='file' ... |
Textarea | <textarea>...</textarea> |
CheckboxInput | <input type='checkbox' ... |
Select | <select><option ... |
NullBooleanSelect | Select widget with options Unknown, Yes, and No |
SelectMultiple | <select multiple='multiple'><option ... |
RadioSelect | <ul><li><input type='radio' ... |
CheckboxSelectMultiple | <ul><li><input type='checkbox' ... |
MultiWidget | Wrapper around multiple other widgets |
SplitDateTimeWidget | Wrapper around two TextInput widgets: one for the Date and one for the Time |