python - edit django form widget rendering -


i have django form 1 of fields defined as:

widgets = {     'name': forms.checkboxselectmultiple() } 

the template renders them in loop with:

{% field in form %}     <fieldset class="article-form__field">         {{ field.label_tag }} {{ field }}     </fieldset> {% endfor %} 

this rendered as:

<fieldset class="article-form__field">     <label for="category-name_0">category:</label>     <ul id="category-name">         <li><label for="category-name_0"><input id="category-name_0" name="category-name" type="checkbox" value="gen" /> general information</label></li>         <li><label for="category-name_1"><input id="category-name_1" name="category-name" type="checkbox" value="foo" /> food , drinks</label></li>     </ul> </fieldset> 

in short: <label><input></label>. however, output <label></label><input>.

is possible, , if so, how?

full code here.

{% field in form %}     <fieldset class="article-form__field">     {% if field.name != "category-name" %}         {{ field.label_tag }} {{ field }}     {% else %}         {{ field.label_tag }}         <ul id={{ field.auto_id }}>         {% checkbox in field %}             <li>                  <label for="{{ checkbox.id_for_label }}">                     {{ checkbox.choice_label }}                 </label>                 {{ checkbox.tag }}             </li>         {% endfor %}         </ul>     {% endif %}     </fieldset> {% endfor %} 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -