我想is_active在Flask-Login中进行修改,以便用户不会始终处于活动状态.
默认值始终返回True,但我更改了它以返回banned列的值.
根据文档,is_active应该是一个属性.但是,内部Flask-Login代码引发:
TypeError: 'bool' object is not callable
Run Code Online (Sandbox Code Playgroud)
试图使用时is_active.
如何正确使用is_active停用某些用户?
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
banned = db.Column(db.Boolean, default=False)
@property
def is_active(self):
return self.banned
Run Code Online (Sandbox Code Playgroud)
login_user(user, form.remember_me.data)
if not force and not user.is_active():
TypeError: 'bool' object is not callable
Run Code Online (Sandbox Code Playgroud)