flask报错:“Exception: Unexpected end of template. Jinja was looking for the following tags: 'endfor' ”
flask报错:“Exception: Unexpected end of template. Jinja was looking for the following tags: ‘endfor’ ”
报错详情:
Exception: Unexpected end of template. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.
Exception: Unexpected end of template. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.
127.0.0.1 - - [26/Dec/2018 12:29:38] "GET /admin/login/ HTTP/1.1" 302 -
Exception: Unexpected end of template. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.
127.0.0.1 - - [26/Dec/2018 12:29:38] "GET /admin/login/ HTTP/1.1" 302 -
报错原因:jinja语句中 “ % ” 和 “ { ” 之间有空格
{% for msg in get_flashed_messages() %}
<p class="login-box-msg" style="color: red">{{ msg }}</p>
{ % endfor %}
解决方法:去除空格
{% for msg in get_flashed_messages() %}
<p class="login-box-msg" style="color: red">{{ msg }}</p>
{% endfor %}