[Answer]-Django template: Invalid block tag: 'endif', expected 'empty' or 'endfor'

1👍

Add {% endfor %}{% endif %} to the last line of code.

0👍

For loops require endfor tags

{% if mike %}
  {% if jake %}
    {% for x in squid %}
      {{ x.do_stuff }}
    {% endfor %}
  {% endif %}{# closes jake tag #}
{% endif %}{# closes mike tag #}

Leave a comment