Django:第 49 行的无效块标签:"endfor",预期的"elif",'else' 或"endif"。您是否忘记注册或加载此标签?



我的.html模板有问题。无法计算第 49 行的错误。说预期的endif,我实际上在代码上有它。

错误说:

第 49 行的块标记无效:"endfor",预期的"elif"、"else"或"endif"。

44                      {% if messages %}
45                          {% for message in messages % }
46                              <div class=" alert alert-{{message.tag}}">
47                                  {{message}}
48                              </div>
49                          {% endfor %}
50                      {% endif %}

任何帮助都会非常感激。

您可能会在这里遇到错误:

1% }之间的空间太大

{% for message in messages %}

最新更新