Answer the question
In order to leave comments, you need to log in
How to assign classes to checkboxes using django-widget-tweaks?
forms.CheckboxSelectMultiple generates a list of checkboxes like this:
<ul id="id_items">
<li><label for="id_items_0"><input type="checkbox" name="items" value="1" checked id="id_items_0">
Item1</label>
</li>
<li><label for="id_items_1"><input type="checkbox" name="items" value="2" checked id="id_items_1">
Item2</label>
</li>
<li><label for="id_items_2"><input type="checkbox" name="items" value="3" checked id="id_items_2">
Item3</label>
</li>
<li><label for="id_items_3"><input type="checkbox" name="items" value="4" checked id="id_items_3">
Item4</label>
</li>
<li><label for="id_items_4"><input type="checkbox" name="items" value="5" checked id="id_items_4">
Item5</label>
</li>
<li><label for="id_items_5"><input type="checkbox" name="items" value="6" checked id="id_items_5">
Item6</label>
</li>
</ul>
{% for field in formEx %}
{% render_field field|append_attr:"class:test" %}
{% endfor %}
Answer the question
In order to leave comments, you need to log in
It turned out with the help of django-crispy-forms. Just this entry and that's it:{{ formEx|crispy }}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question