Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'bool' object has no attribute '__call__' when visiting localhost:5000 #9

Open
nealwright opened this issue Sep 11, 2015 · 10 comments

Comments

@nealwright
Copy link

I followed the installation instructions and all of the requirements install successfully. I'm using the newest version of virtualenvwrapper. When I visit localhost:5000 I get the following error:

File "[path_to_project]/app/templates/layout.html", line 29, in block "body" 
{% if current_user.is_authenticated() %}
AttributeError: 'bool' object has no attribute '__call__'

I'm somewhat new to flask and to Python, apologies if this is not a problem with the application itself, but I am stumped as to how to fix it. I googled a couple of solutions and haven't found anything that works. Thank you!

@jamescarignan
Copy link

I encountered this issue as well, and spent far too long in determining that it's caused by Flask-Login. They changed current_user.is_authenticated() to be a property in 0.3.0, and thus making a method call here generates this error. This will need to be updated in Flask-User, I'm going to submit a pull request shortly. In the meantime, you can downgrade to Flask-Login==0.2.11 which won't have those changes in yet(but I have no idea if that will break anything else - I'm guessing not, but caveat emptor).

@nealwright
Copy link
Author

Thank you! Really appreciate it. Yeah, it would be great to get this fixed. In the meantime I'll downgrade Flask-Login.

Edit: I tried this and got the following error:

UndefinedError: 'flask_login.AnonymousUserMixin object' has no attribute 'user_auth'

I might just go through and change it manually for the moment. Looks like it's only two files, views.py and decorators.py that need changes I believe.

@jamescarignan
Copy link

Truth be told, I didn't really look at the changelist for 0.3.0, I was hoping it was just that one issue. FYI I'm using my patched version, and was able to go through the whole user registration/login/logout flow, so I suspect that the fix won't be that far out. You can track its progress here: lingthio/Flask-User#91

@AdamSun
Copy link

AdamSun commented Jan 20, 2016

I met this problem.I am using flask-login for the version of 0.3.2. As jamescarignan said,I use "current_user.is_authenticated" instead of "current_user.is_authenticated()" and it seems works, has no idea if there is another problem.has this be fixed? thx!

@guinslym
Copy link

guinslym commented Mar 1, 2016

as @AdamSun and @jamescarignan . I actually had to write 'current_user.is_authenticated" without the parenteses at the end

@Max-AR
Copy link

Max-AR commented Mar 8, 2016

I have the exact same problem as well. I am using;
Flask-User (0.6.8) Flask-Login (0.3.2) Flask (0.10.1) Python 3.4.3+
@AdamSun and @jamescarignan that solution seems to work for me at this stage.

@Charlie37
Copy link

Exact same problem here. Like @guinslym , I now use {% if (current_user.is_authenticated) %} and it seems to work.

@battouly
Copy link

I had the same issue and just removed the parentheses after authenticated.
You should use "current_user.is_authenticated" instead of "current_user.is_authenticated()"

andriyor added a commit to andriyor/Google-Oauth2-login-Flask that referenced this issue Apr 4, 2017
@lv10
Copy link

lv10 commented Apr 22, 2017

Same issue here, I get the same problem whether I use "current_user.is_authenticated" or "current_user.is_authenticated()".

@HiIcy
Copy link

HiIcy commented Jun 26, 2017

wonderful!! I got that issue as well,and I adopt the way you said, wipe off "()",Using "current_user.is_authenticated" instead of "current_user.is_authenticated()"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants