g.current_user请教下是不是必须得这么写?
来源:9-8 登录功能实现(2)

慕慕7551115
2021-07-04
老师,请教下,g.current_user请教下是不是必须得这么写?比如写成g.current_user1是否就不行?
开始我以为这是随便定义的,后来发现如果写成其他值如:g.current_user1,导致后续登录成功后,用户名获取不到
1回答
-
慕慕7551115
提问者
2021-07-04
File "D:\process\python\process\maoyan\templates\index.html", line 1, in top-level template code
{% extends "common/layout.html" %}
File "D:\process\python\process\maoyan\templates\common\layout.html", line 36, in top-level template code
<li><a href="javascript:void(0);">{{current_user1.nickname}}</a></li>
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\jinja2\environment.py", line 474, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'current_user' is undefined
INFO:werkzeug:127.0.0.1 - - [04/Jul/2021 19:00:10] "GET / HTTP/1.1" 500 -
012021-08-28
相似问题