If I do not understand your question, check in the comments.
The Django Form Widgets documentation offers several predefined widgets that you can use to indicate how the field is displayed in your form.
Without changing the code in my views, I can simply add the widget keyword to the appropriate form fields.
forms.py (v1)
class TestForm(forms.Form): CHOICES = ( (1, "choice1"), (2, "choice2"), (3, "choice3"), ) field = forms.ChoiceField(choices=CHOICES)
Select is displayed as a drop-down list:
<select id="id_field" name="field"> <option value="1">choice1</option> <option value="2">choice2</option> <option value="3">choice3</option> </select>
Now add the widget keyword to my field:
forms.py (v2)
field = forms.ChoiceField(choices=CHOICES, widget=forms.CheckboxSelectMultiple)
This displays a list of checkboxes:
<ul id="id_field"> <li> <label for="id_field_0"><input id="id_field_0" name="field" type="checkbox" value="1" /> choice1</label> </li> <li> <label for="id_field_1"><input id="id_field_1" name="field" type="checkbox" value="2" /> choice2</label> </li> <li> <label for="id_field_2"><input id="id_field_2" name="field" type="checkbox" value="3" /> choice3</label> </li> </ul>
Edit
You can also add widgets that are used by the Django administrator. See the Django multi-user widget for more details ? . Just import the corresponding widget:
from django.contrib.admin.widgets import FilteredSelectMultiple
and use it instead. Please note that in this particular case, you will also need to include the media form in order to get the desired effect.