{% with id=widget.attrs.id %} {% if widget.attrs.class == 'radiolist' %}
{% for group, options, index in widget.optgroups %} {% if group %}
{% endif %} {% for option in options %}
{% include option.template_name with widget=option %}
{% endfor %} {% if group %}
{% endif %} {% endfor %}
{% else %} {# django multiselect field #}
{% for group, options, index in widget.optgroups %} {% endfor %}
{% endif %} {% endwith %}