提问者:小点点

Django模板语法错误(无效块标记)


我想在我的网站上打开我的预订表单页面,但我出现了这个错误:

TemplateSyntaxError at /form.html/
 Invalid block tag on line 61: 'end', expected 'empty' or 'endfor'. Did you forget to register or 
 load this tag?

下面是我的代码:

     {% if messages %}
     {% for message in messages %}
      <h2 style="color: green">{{message}}</h2>
      {% end for %} //the line I got the error
     {% end if %}

共1个答案

匿名用户

结尾和关键字之间不应该有空格。

{% if messages %}
  {% for message in messages %}
    <h2 style="color: green">{{message}}</h2>
  {% endfor %}
{% endif %}