8-1节/course/list报错'Page' object is not iterable
来源:8-1 课程列表
Kaiz不是
2017-01-23
TypeError at /course/list/
'Page' object is not iterable
Request Method:
GET
Request URL:
http://127.0.0.1:8000/course/list/
Django Version:
1.9.8
Exception Type:
TypeError
Exception Value:
'Page' object is not iterable
Exception Location:
/usr/lib64/python2.7/site-packages/django/template/defaulttags.py in render, line 167
Python Executable:
/usr/bin/python2.7
Python Version:
2.7.5
Python Path:
['/home/kaiz/PycharmProjects/MxOnline/extra_apps',
'/home/kaiz/PycharmProjects/MxOnline/apps',
'/home/kaiz/PycharmProjects/MxOnline',
'/home/kaiz/PycharmProjects/MxOnline',
'/home/kaiz/PycharmProjects/MxOnline/apps',
'/home/kaiz/PycharmProjects/MxOnline/extra_apps',
'/usr/lib64/python27.zip',
'/usr/lib64/python2.7',
'/usr/lib64/python2.7/plat-linux2',
'/usr/lib64/python2.7/lib-tk',
'/usr/lib64/python2.7/lib-old',
'/usr/lib64/python2.7/lib-dynload',
'/usr/lib64/python2.7/site-packages',
'/usr/lib64/python2.7/site-packages/gtk-2.0',
'/usr/lib/python2.7/site-packages']
Server time:
星期一, 23 一月 2017 10:07:09 +0800
3回答
-
bobby
2017-01-23
Page' object is not iterable 你理解一下这个报错的意思, 你对page类型的变量进行了for循环你检查一下你的for循环并检查传递进去的类型是不是Page类型的
012017-01-23 -
慕的地1353516
2019-08-04
我也遇到这个问题,百度了解决方法:
修改其原文件
打开paginator.py文件
在文件最后添加
def __iter__(self):
for i in self.object_list:
yield i参考:https://blog.csdn.net/weixin_44352981/article/details/86616326
10 -
Kaiz不是
提问者
2017-01-23
CourseListView里面
courses = p.page(page)
这个类型是page
012017-01-23
相似问题