[Answered ]-Django template if inside a for loop – Invalid block tag on line 13: 'else', expected 'empty' or 'endfor'.

2👍

You are not closing the if template tag correctly. You are closing with }, whereas it needs %}.

Try this:

{% for letter in "ABCD"|make_list %}

    {% if letter == 'A' or letter == 'D' %}
        Yes
    {% else %}
        No
    {% endif %}

{% endfor %}
👤nik_m

Leave a comment