0

I'm getting Invalid block tag: 'else'

The code is rather simple:

<tr>
<td>...</td>
</tr>
{% ifequal var1 "string" %}
    {% for i in range5 %}
            {% with v.i as an %}
        {% if an %}
            <tr>
            <td>...</td>
            </tr>
        {% else %}
            <tr>
            <td style="background-color:#A8A8A8">&nbsp;</td>
            </tr>
        {% endif %}
        {% endwith %}
        {% endfor %}
            <tr>
            <td style="background-color:#A8A8A8">&nbsp;</td>
            </tr>
ERROR HERE --> {% else %}
                    {% for i in range5 %}
            {% with .. %}
            {% if .. %}
            <tr>
        <td>></td>
            </tr>
            {% else %}
            <tr>
                <td style="background-color:#A8A8A8">&nbsp;</td>
            </tr>
            {% endif %}
            {% endwith %}
            {% endfor %}
            {% endifequal %}
2
  • I dont see {% endifequal %} Commented Jul 18, 2013 at 12:48
  • @user710907 this is omitted - after the {% else %} Commented Jul 18, 2013 at 12:57

1 Answer 1

1

And else tag must be within an if tag in django templates. The last else tag does not fall into any if tag since you ended the if statement with endif.

Sign up to request clarification or add additional context in comments.

7 Comments

Can't I use else within ifequal ?
@ftkg: Yes you most certainly can.
Well, there's a ifequal tag open, so else should be eligible?
{% ifequal %} can have an else followed by {% endifequal %} In your case, you have a dangling {% else %} which is invalid. Just put an {% endifequal %} after the {% else %} to see what i mean.
@karthikr @ftkg, its as he says, all that matters is the endif.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.