使用 Flask/Jinja 关闭循环时出错
Error closing out for loop using Flask/Jinja
我正在使用 Flask 将网站连接到 SQLite3 中的数据库。尝试遍历 table 结果,我使用以下代码,该代码基于 Flaskr 教程 (http://flask.pocoo.org/docs/0.10/tutorial/templates/):
`{% extends "layout.html" %}
{% block body %}
<ul class="students">
{% for student in students %}
<li>{{ student.ID }},{{ student.lastName }},{{ student.firstName }}</li>
{% else %}
<li> No students yet</li>
{% endfor % }
</ul>`
但我收到一条错误消息:
File "C:\sam\IS13\templates\show_tests.html", line 8, in template
{% endfor % }
TemplateSyntaxError: expected token 'end of statement block', got '%'
这不是关闭此设置中的 for 循环的正确方法吗?
关闭控制应该是{% endfor %}
,%
和}
之间没有space。
我正在使用 Flask 将网站连接到 SQLite3 中的数据库。尝试遍历 table 结果,我使用以下代码,该代码基于 Flaskr 教程 (http://flask.pocoo.org/docs/0.10/tutorial/templates/):
`{% extends "layout.html" %}
{% block body %}
<ul class="students">
{% for student in students %}
<li>{{ student.ID }},{{ student.lastName }},{{ student.firstName }}</li>
{% else %}
<li> No students yet</li>
{% endfor % }
</ul>`
但我收到一条错误消息:
File "C:\sam\IS13\templates\show_tests.html", line 8, in template
{% endfor % }
TemplateSyntaxError: expected token 'end of statement block', got '%'
这不是关闭此设置中的 for 循环的正确方法吗?
关闭控制应该是{% endfor %}
,%
和}
之间没有space。