Flask-Jinja:未定义的错误

时间:2017-12-31 04:56:49

标签: python sqlite jinja2

我是Flask和python的新手,我不知道我做错了什么但是我得到了这个erorr" UndefinedError:' intel'未定义"

app.route('/dashboard')
@login_required
def dashboard():
    print current_user.username
    intels = Slam.query.filter_by(urname ='ganesh14').all()
    return render_template('dashboard.html',intels = intels)

html页面:

<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          <h1 class="page-header">Welcome</h1>
          { % if intels % }
            { % for intel in intels %}
              <h3> {{ intel.Myname }} </h3>
              <h3> {{ intel.Mymail }} </h3>
              <h3> {{ intel.Memmom }} </h3>
              <h3> {{ intel.Likes }}  </h3>
              <h3> {{ intel.Dontlikes }}  </h3>
              <h3> {{ intel.Aboutme }}  </h3>
            { %endfor% }
          { %endif% }
      </div>

这是Partial追溯,因为我真的无法摆脱主要的代码消息。

  File "/home/hanlak/.local/lib/python2.7/site-packages/flask_bootstrap/templates/bootstrap/base.html", line 20, in block "html"
    {% block body -%}
  File "/home/hanlak/.local/lib/python2.7/site-packages/flask_bootstrap/templates/bootstrap/base.html", line 23, in block "body"
    {% block content -%}
  File "/home/hanlak/PycharmProjects/flaskProj/start/templates/dashboard.html", line 38, in block "content"
    <h3> {{ intel.Myname }} </h3>
  File "/home/hanlak/.local/lib/python2.7/site-packages/jinja2/environment.py", line 430, in getattr
    return getattr(obj, attribute)
UndefinedError: 'intel' is undefined

0 个答案:

没有答案