layout_main添加current_user.nicknam后点击,仪表盘中账号管理等报错问题
来源:7-5 编辑和修改登录人信息
慕丝0417419
2021-01-25
老师,这节课就改了current_user,然后就导致了current_报错。
jinja2.exceptions.UndefinedError
jinja2.exceptions.UndefinedError: ‘current_user’ is undefined
Traceback (most recent call last)
File “/root/imooc_env/lib/python3.7/site-packages/flask/app.py”, line 2464, in call
return self.wsgi_app(environ, start_response)
File “/root/imooc_env/lib/python3.7/site-packages/flask/app.py”, line 2450, in wsgi_app
response = self.handle_exception(e)
File “/root/imooc_env/lib/python3.7/site-packages/flask/app.py”, line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File “/root/imooc_env/lib/python3.7/site-packages/flask/_compat.py”, line 39, in reraise
raise value
File “/root/imooc_env/lib/python3.7/site-packages/flask/app.py”, line 2447, in wsgi_app
response = self.full_dispatch_request()
File “/root/imooc_env/lib/python3.7/site-packages/flask/app.py”, line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/root/imooc_env/lib/python3.7/site-packages/flask/app.py”, line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/root/imooc_env/lib/python3.7/site-packages/flask/_compat.py”, line 39, in reraise
raise value
File “/root/imooc_env/lib/python3.7/site-packages/flask/app.py”, line 1950, in full_dispatch_request
rv = self.dispatch_request()
File “/root/imooc_env/lib/python3.7/site-packages/flask/app.py”, line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File “/home/www/order/web/controllers/account/Account.py”, line 9, in index
return render_template(“account/index.html”)
File “/root/imooc_env/lib/python3.7/site-packages/flask/templating.py”, line 140, in render_template
ctx.app,
File “/root/imooc_env/lib/python3.7/site-packages/flask/templating.py”, line 120, in _render
rv = template.render(context)
File “/root/imooc_env/lib/python3.7/site-packages/jinja2/environment.py”, line 1090, in render
self.environment.handle_exception()
File “/root/imooc_env/lib/python3.7/site-packages/jinja2/environment.py”, line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File “/root/imooc_env/lib/python3.7/site-packages/jinja2/_compat.py”, line 28, in reraise
raise value.with_traceback(tb)
File “/home/www/order/web/templates/account/index.html”, line 1, in top-level template code
{% extends “common/layout_main.html” %}
File “/home/www/order/web/templates/common/layout_main.html”, line 74, in top-level template code
姓名:{{ current_user.nickname }} 编辑
File “/root/imooc_env/lib/python3.7/site-packages/jinja2/environment.py”, line 471, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: ‘current_user’ is undefined
删除框内参数则恢复正常请问老师是什么原因导致的呢?网上搜索了说是要添加宏之类的但是我不太懂。麻烦老师帮忙解答,谢谢。
2回答
-
编程浪子
2021-01-28
你好
这个 956439035 是的扣扣是把,我加你的了
00 -
编程浪子
2021-01-26
你好
我刚觉你复制错了模板,你复制的是应该是完全源码里面的页面。current_user 是一个变量,后续会有讲解的
如下链接应该才是对的
012021-01-28
相似问题