Django Paginator和拉链

发布于 2025-01-26 04:49:37 字数 258 浏览 4 评论 0原文

我想在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一场春暖 2025-02-02 04:49:37

您的item2page对象第二次将其缩小。因此,大概您会按照以下方式进行……

{{ item2.next_page_number }}

Your item2 is the Page object as you zipped it second. So presumably you would do it as follows…

{{ item2.next_page_number }}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文