Django出现报错'AnonymousUser' object is not iterable
2017-11-13 23:12
288 查看
django 做的网站出现如下错误:
错误代码最终定位在view视图:
错误分析,此功能必须经过验证登录的用户才能使用,没登录的用户使用了此功能导致报错,解决办法,在报错的代码前面加上如下代码:
问题解决
Exception Type: TypeError Exception Value:'AnonymousUser' object is not iterable
错误代码最终定位在view视图:
if UserFavorite.objects.filter(user=request.user, fav_type=2,av_id=teacher.org.id):
错误分析,此功能必须经过验证登录的用户才能使用,没登录的用户使用了此功能导致报错,解决办法,在报错的代码前面加上如下代码:
if request.user.is_authenticated(): if UserFavorite.objects.filter(user=request.user, fav_type=3, fav_id=teacher.id):
问题解决
相关文章推荐
- Python出现TypeError: 'NoneType' object is not iterable
- DJANGO问题--Error: ‘ManyRelatedManager’ object is not iterable
- Django 报错 'AnonymousUser' object is not iterable 的解决办法
- Python 出现错误TypeError: ‘NoneType’ object is not iterable解决办法
- Django: TypeError: 'MediaDefiningClass' object is not iterable
- usecols = list(usecols) TypeError: 'int' object is not iterable
- 安装PostgreSQL出现“Invalid username specified:登录失败:未知的用户名和错误密码。”和“The specified data directory is not empty.”错误的解决方案
- 运行React Native示例出现null is not an object (evaluating 'this.state.text')
- python TypeError: 'int' object is not iterable
- django object is not JSON serializable error问题解决
- Anaconda下import caffe出现错误TypeError: 'module' object is not callable
- python3中,socket使用send函数时出现的错误:TypeError: a bytes-like object is required, not 'str'
- django session object is not JSON serializable
- python mysql 插入数据报错 Failed processing format-parameters; 'int' object is not iterable
- 错误:document.getElementById("userForm").submit();Object is not a function
- python 安装pandas 出现InsecurePlatformWarning: A true SSLContext object is not available.
- SSH实现登陆功能时出现user is not mapped [FROM USER WHERE username =? and password=? 错误
- Python中3+版本运行2+版本程序出现TypeError: a bytes-like object is required, not 'str'之读取PDF中的图片
- python TypeError: 'builtin_function_or_method' object is not iterable keys
- TypeError:a bytes-like object is requeired ,not 'int'(使用python3编写出现的错误)