Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"TypeError: 'bool' object is not callable" in flask

I have is_active = db.Column(db.Boolean(), nullable=False) field in user model in my flask app now when am loging in, I get the error TypeError: 'bool' object is not callable

Traceback

.
.
.
File "/home/environments/flask0101/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/flask/myapp/app/auth/views.py", line 15, in  login
login_user(user)
File "/home/environments/flask0101/lib/python2.7/site-packages/flask_login.py", line 675, in login_user
if not force and not user.is_active():
TypeError: 'bool' object is not callable

What is the issue?

like image 456
Alexxio Avatar asked Dec 20 '22 10:12

Alexxio


1 Answers

is_active is bool object.

>>> is_active = True
>>> is_active()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'bool' object is not callable

Just use it as a predicate, instead of calling it:

if not force and not user.is_active:
    ...
like image 80
falsetru Avatar answered Dec 28 '22 07:12

falsetru