我有一个小瓶的应用这使得博客文章:瓶mongoengine分页
views.py:
class ListView(MethodView):
def get(self, page=1):
posts = Post.objects.all()
return render_template('posts/list.html', posts=posts)
这一切都不错,但我想分页添加到posts
对象。看看project docs,我看到有一个分页类。
所以,我想这一点:
class ListView(MethodView):
def get(self, page=1):
posts = Post.objects.paginate(page=page, per_page=10)
return render_template('posts/list.html', posts=posts)
但现在我得到一个错误:
TypeError: 'Pagination' object is not iterable
那么,如何遍历我的模板posts
?
任何帮助非常感谢。
什么是你的温度后期代码?你可以分享吗? – codegeek 2013-04-04 23:50:07