0

我越来越Invalid block tag: 'else'

代码相当简单:

<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 %}
4

1 回答 1

1

并且else标签必须if在 django 模板中的标签内。自从您以 结束语句以来,最后一个else标签不属于任何标签。ififendif

于 2013-07-18T12:37:42.607 回答