我正在为我正在制作的这个烧瓶应用程序使用 jinja,当我运行它时 jinja2.exceptions.undefined错误:出现未定义'user'



所以,我用它来渲染一个模板,我有。这是它有问题的代码。'

@views.route('/')
def home():
return render_template("home.html")

'顺便说一下,这是home。html

中的代码
{% extends "base.html" %} {% block title %}Home{% endblock %} {% block content
%}
<h1 align="center">Notes</h1>
<ul class="list-group list-group-flush" id="notes">
{% for note in user.notes %}
<li class="list-group-item">
{{ note.data }}
<button type="button" class="close" onClick="deleteNote({note,id })"
<span aria-hidden="true">&times;</span>
</button>
</li>
{% endfor %}
</ul>
<form method="POST">
<textarea name="note" id="note" class="form-control"></textarea>
<br />
<div align="center">
<button type="submit" class="btn btn-primary">Add Note</button>
</div>
</form>
{% endblock %}

我运行它。它给了我一个网站链接。那里的一切,不。我运行它。它给了我一个网站链接。然后是jinja2,例外。UndefinedError: 'user' is undefined is my website

检查你的html文件,你可能不小心在那里得到一个名为user的变量

最新更新