Django Paginator和拉链
我想在HTML渲染中迭代列表和查询,但无法让Django Paginator工作。我将列表和QuerySet拉开,这样我就可以将它们一起迭代。 这是我的视图
。使用{%item1,posts%}中的item2,但是{{posts.next_page_number}}只是空白。如何访问模板引擎中的页面?
I want to iterate a list and query set in my html render, but am unable to get the Django paginator to work. I zipped the list and queryset so I could iterate them together.
Here's my views.py code.
Oddly enough, I am able to access the data in both lists with {% for item1, item2 in posts %}, but {{ posts.next_page_number }} is just blank. How can I access the page in the templating engine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
item2
是page
对象第二次将其缩小。因此,大概您会按照以下方式进行……Your
item2
is thePage
object as you zipped it second. So presumably you would do it as follows…