{# this is the version from django 3.x, prior to https://github.com/django/django/commit/5942ab5eb165ee2e759174e297148a40dd855920 so that django-bootstrap3 can keep doing its magic #}
{% with id=widget.attrs.id %}
{% for group, options, index in widget.optgroups %}{% if group %}
{{ group }}
{% endif %}{% for option in options %}
{% include option.template_name with widget=option %}