forms.py
class TypeSelectionForm(forms.Form):
checkbox_field = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(), label=\"\", required=Fals
Why not use the power of Django template tags ?
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
@register.filter("as_div")
def as_div(form):
form_as_div = form.as_ul().replace("
Put that in a template tag and then do this simply in your template
{% load ad_div %}
{# some Code #}
{{ form|as_div }}
{# some other code #}
============================
Another approach would be to extend django forms model
as follows
from django.forms.forms import BaseForm
Class AsDiv(BaseForm):
def as_div(self):
return self._html_output(
normal_row = u'%(errors)s%(label)s %(field)s%(help_text)s',
error_row = u'%s',
row_ender = 'Then you could just do this is your template
{{ form.as_div }}