Flask--AttributeError 'bool' object has no attribute '__call__'
2016-03-05 13:13
501 查看
2016年3月1日
在学习Flask-Login模块时,出现了报错
参考资料:When I run app.py, why am I getting: builtins.AttributeError AttributeError: ‘bool’ object has no attribute ‘call’
Kenneth Love: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.
原因:flask-login 模块里的
解决办法:去掉
在学习Flask-Login模块时,出现了报错
builtins.AttributeError AttributeError: 'bool' object has no attribute '__call__'。
参考资料:When I run app.py, why am I getting: builtins.AttributeError AttributeError: ‘bool’ object has no attribute ‘call’
Kenneth Love: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.
原因:flask-login 模块里的
UserMixin类由于版本更新后,修改了它的
is_authenticated()方法,在之前的版本中是使用
UserMixin.is_authenticated()根据用户已经登录返回
True,未登录返回
False,而现在改成使用
UserMixin.is_authenticated了。上文中的Kenneth Love表示虽然这是个烦人的改变,但他认为这是一种更好的代码设计。
解决办法:去掉
is_authenticated()中的括号。
相关文章推荐
- Objective-C Runtime 一小时入门教程(上)
- SPRING IN ACTION 第4版笔记-第六章RENDERING WEB VIEWS-006- 使用thymeleaf(TemplateResolver、SpringTemplateEngine、ThymeleafViewResolver、th:include、th:object、th:field="*{firstName}")
- 包装类、object、单例模式、final、抽象类
- Spring MVC 提示: Neither BindingResult nor plain target object for bean
- iOS、OC和Objective-C的区别
- 如何判断List<Object>中是否包含,一个有相同xxx某个属性实体类
- C++中关于静态对象的使用( local static object and global static object)
- C++中关于静态对象的使用( local static object and global static object)
- Object-C官方文档翻译——Block
- Objective的宏到swift中该怎么办?
- 在界面线程不能使用Sleep和WaitForSingleObject之类的函数, 使用 MsgWaitForMultipleObjects
- Objective-C 单例模式
- objective -c之分类,协议。
- 011_用eclipse打开hadoop1.2.1源码出现The method getSplits(JobConf, int) is undefined for the type Object错误
- SuperMap iObjects.NET 在洪涝灾害中的简单应用
- 引用CYLTabBarController记录
- Objective-c 协议(Protocol)
- Objective-C之类和对象
- SuperMap iObjects .NET 制作2.5D数据详解(二)
- net.sf.json.JSONObject 和org.json.JSONObject 的差别