Flask 上的 AttributeError: 'bool' object has no attribute '__call__'问题

这基本上是flask-login版本问题

1.下面这段文字没准能帮到你Posting this here so people can see it, this comes from a change in how UserMixin works in flask-login. I'd tell you to install a specific version of flask-login but...they removed those releases from PyPI.

So...instead of {{ current_user.is_authenticated() }}, you need to use {{ current_user.is_authenticated }}. Just don't include the parentheses. Yeah, it's an annoying change but, honestly, I think it's probably better code design.

2.lask-login的版本问题,flask-login2.x是current_user.is_authenticated(),flask-login3.x是current_user.is_authenticated。避免这个问题最好的办法就是使用虚拟环境并在requirement中写明版本号。

current_user.is_authenticated()基本出现在视图函数(views.py)和模板(templates)里面。

原文地址:https://www.cnblogs.com/Hondsome/p/5985013.html