请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

5-1 15:00老师界面可以刷出仪表盘,但自己报错UndefinedError: 'current_user' is undefined

5-1 15:00此刻老师界面可以刷出仪表盘界面,但是我自己的不行,报错jinja2.exceptions.UndefinedError: ‘current_user’ is undefined
图片描述

具体报错全部内容如下:

jinja2.exceptions.UndefinedError
jinja2.exceptions.UndefinedError: ‘current_user’ is undefined

Traceback (most recent call last)
File “C:\Python35\lib\site-packages\flask\app.py”, line 2309, in call
return self.wsgi_app(environ, start_response)
File “C:\Python35\lib\site-packages\flask\app.py”, line 2295, in wsgi_app
response = self.handle_exception(e)
File “C:\Python35\lib\site-packages\flask\app.py”, line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File “C:\Python35\lib\site-packages\flask_compat.py”, line 35, in reraise
raise value
File “C:\Python35\lib\site-packages\flask\app.py”, line 2292, in wsgi_app
response = self.full_dispatch_request()
File “C:\Python35\lib\site-packages\flask\app.py”, line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File “C:\Python35\lib\site-packages\flask\app.py”, line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “C:\Python35\lib\site-packages\flask_compat.py”, line 35, in reraise
raise value
File “C:\Python35\lib\site-packages\flask\app.py”, line 1813, in full_dispatch_request
rv = self.dispatch_request()
File “C:\Python35\lib\site-packages\flask\app.py”, line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File “D:\Work\Python\wxminiapp\miniaec_self\web\controllers\index.py”, line 11, in index
return render_template( “index/index.html”)
File “C:\Python35\lib\site-packages\flask\templating.py”, line 135, in render_template
context, ctx.app)
File “C:\Python35\lib\site-packages\flask\templating.py”, line 117, in _render
rv = template.render(context)
File “C:\Python35\lib\site-packages\jinja2\environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “C:\Python35\lib\site-packages\jinja2\environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “C:\Python35\lib\site-packages\jinja2_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File “D:\Work\Python\wxminiapp\miniaec_self\web\templates\index\index.html”, line 1, in top-level template code
{% extends “common/layout_main.html” %}
File “D:\Work\Python\wxminiapp\miniaec_self\web\templates\common\layout_main.html”, line 74, in top-level template code
姓名:xxxx 编辑
File “C:\Python35\lib\site-packages\jinja2\environment.py”, line 430, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: ‘current_user’ is undefined
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the “Traceback” headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that’s known about the object

正在回答 回答被采纳积分+3

2回答

慕雪0339225 2019-09-02 16:17:11

遇到了同样问题,怎么解决的?

0 回复 有任何疑惑可以回复我~
提问者 Momo2k19123 2018-12-16 22:04:55

已经解决。

原因:刷新前端页面前没有定义user的路由,登录、编辑和重设密码。

解决:前面跟学的时候,跟得比较紧,下面黄色框中的内容其实都还是空白。而老师讲课跳过了这个部分。先刷新了仪表盘,显示了前端页面。


https://img1.sycdn.imooc.com//szimg/5c165aaf0001e29611620965.jpg

0 回复 有任何疑惑可以回复我~
  • 看不懂你说的 这里需要怎么解决?
    回复 有任何疑惑可以回复我~ 2019-01-14 19:11:52
  • 求解答
    回复 有任何疑惑可以回复我~ 2019-09-02 17:09:20
  • vigigo 回复 慕雪0339225 #3
    应该解决了哈,不懂的同学你看一下你的templates/commom下的文件有多少,应该是只有layout_main 和 layout_user 的,如果不是,就会导致索引出现问题,因为你复制的应该是完整的代码,但是课程代码不是这样的,课程代码中的html中对于currentname是由名曲的设定的,而不是调用,你如果用的是完整代码,那么你会发现你没有可以调用的名字,你需要登录,然后又没有设置登录接口
    回复 有任何疑惑可以回复我~ 2019-11-11 19:13:14
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信