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语句中 “ % ” 和 “ { ” 之间有空格

flask报错:“Exception: Unexpected end of template. Jinja was looking for the following tags: 'endfor' ”_第1张图片

{% for msg in get_flashed_messages() %}
     
{  % endfor %}

解决方法:去除空格

在这里插入图片描述

{% for msg in get_flashed_messages() %}
    
{% endfor %}

你可能感兴趣的:(flask报错:“Exception: Unexpected end of template. Jinja was looking for the following tags: 'endfor' ”)