我的《flask web 学习》错误集锦
报错:jinja2.exceptions.TemplateSyntaxError: unexpected ‘%’
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ user.username }}'s Watchlist</title>
</head>
<body>
<a href="{{ url_for('index')}}">←Return</a>
<h2>{{ user.username}}</h2>
{% if user.bio %}
<i>{{user.bio}}</i>
{% else %}
<i>This user has not provided a bio.</i>
{% endif %}
{# 下面是电影清单 #}
<h5>{{ user.usename }}'s Watchlist ({{movies | length}}):</h5>
<ul>
{% for movie in movies %}
<li>{{movie.name}} - {{movie.year}}</li>
{{% endfor %}}
</ul>
</body>
</html>
错误代码 {{% endfor %}}
错误原因:多写了一个大括号