所以,我用它来渲染一个模板,我有。这是它有问题的代码。'
@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">×</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的变量