flask報錯:“Exception: Unexpected end of template. Jinja was looking for the following tags: 'endfor' ”
阿新 • • 發佈:2018-12-26
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 %}