按老师一步一步来的,报错

来源:3-2 Flask实现登录验证

慕神3107089

2021-05-18 11:37:10

http://img.mukewang.com/climg/60a335e909051bcf10330128.jpg

http://img.mukewang.com/climg/60a3362a092c174205640167.jpg

@property
def is_authenticated(self):
return True

@property
def is_active(self):
"""有效的用户才能登陆系统"""
   return self.status == constants.UserStatus.USER_ACTIVE.value

@property
def is_anonymous(self):
return False

def get_id(self):
return '{}'.format(self.id)
# 1.查找对应的用户
# todo 验证加密后的密码是否正确
user = User.query.filter_by(username=username, password=password).first()
# 2.登录用户
# session['user_id'] = user.id  # user.id添加到session会话
login_user(user)
{#<div>{{ g.current_user.nickname }}</div>#}
{% if current_user.is_authenticated %}
<div>{{ cuttent_user.nickname }}</div>
{% endif %}

​真的疑惑

写回答

1回答

时间,

2021-05-18

同学,你好!应该是current_user,同学写错了,因此报错

http://img.mukewang.com/climg/60a3395b095fc34306910091.jpg

http://img.mukewang.com/climg/60a338df09bcc96105930099.jpg

祝学习愉快!​

0

0 学习 · 2433 问题

查看课程