Skip to content

Instantly share code, notes, and snippets.

@sanjaykrishnan
Created April 6, 2020 05:20
Show Gist options
  • Save sanjaykrishnan/c98b6112793e3011695d8f729fbcf759 to your computer and use it in GitHub Desktop.
Save sanjaykrishnan/c98b6112793e3011695d8f729fbcf759 to your computer and use it in GitHub Desktop.
Implementing checkbox for many to many fields
{% for widget in form.field_name %}
<tr>
<th>
<label for="{{widget.id_for_label}}">
<input type="{{widget.data['type']}}" name="{{widget.data['name']}}" value="{{widget.data['value']}}" {% if widget.data['selected'] %}selected{% endif %} {% for k, v in widget.data['attrs'].items() %} {{k}}="{{v}}" {% endfor %}>
</label>
</th>
<td>
{{widget.choice_label}}
</td>
</tr>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment