Django and Custom CheckboxSelectMultipleField
filed in Django, English, Python on Feb.22, 2006
Note: as of Django version 0.95, this solution no longer works. But thanks to the newforms module, it is no longer necessary. Explanation of how it works can be found in this post
The problem: I have been using Django in a project for some weeks. The application needs to display a series of checkboxes on the webpage, but the HTML rendering of the formfields.CheckboxSelectMultipleField class does not offer the precise placement of each checkbox that is needed on the webpage.
formfields.CheckboxSelectMultipleField is a descendant of SelectMultipleField and does not provide the ability to iterate through each of the possible choices, as formfields.RadioSelectField derived objects do:
The Solution: a custom CheckboxesMultipleSelectField based on the code from formfields.RadioSelectField.
CustomCheckboxSelectMultipleField is intended to be used in a custom Manipulator.
The code for the custom CheckboxSelectMultiple




Leave a Reply