Flask--AttributeError 'bool' object has no attribute '__call__'
来源:互联网 发布:仓鼠多少钱一只淘宝上 编辑:程序博客网 时间:2024/06/14 09:55
2016年3月1日
在学习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()
中的括号。
- Flask--AttributeError 'bool' object has no attribute '__call__'
- <<FlaskWeb开发:基于Python的Web应用开发实战>>一处笔误导致AttributeError: 'bool' object has no attribute '__call__'
- 对于AttributeError: 'Flask' object has no attribute 'cli'的解决办法
- AttributeError: 'classmethod' object has no attribute '__module__'
- AttributeError: 'module' object has no attribute 'getpass'
- AttributeError: ‘NoneType’ object has no attribute ‘clone’
- AttributeError: 'module' object has no attribute 'Serial'
- AttributeError: 'NoneType' object has no attribute 'clone'
- AttributeError: 'tuple' object has no attribute 'Multi'
- AttributeError: 'Response' object has no attribute 'json'
- AttributeError: 'module' object has no attribute(转)
- AttributeError: 'Connection' object has no attribute 'connection_errors'
- AttributeError: 'module' object has no attribute 'randint'
- AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
- AttributeError: 'WebDriver' object has no attribute
- AttributeError: 'NoneType' object has no attribute
- AttributeError: 'DisabledBackend' object has no attribute '_get_task_meta_for'
- AttributeError: 'module' object has no attribute 'Serial'
- OSI七层模型
- iOS开发中plist文件的创建与简单读取
- 经典排序算法——冒泡排序
- PythonChallenge之level-2解题报告
- CentOS7安装mysql数据库
- Flask--AttributeError 'bool' object has no attribute '__call__'
- shell学习笔记
- 编程问题之:int i=i
- Win 7中的oracle 11g的TNS-12545错误修复
- PAT_Basic --- 1005
- github 流程介绍
- TCP/IP四层模型
- int和Integer的区别
- Flask--实现密码散列以及@property用法