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?
Your item2
is the Page
object as you zipped it second. So presumably you would do it as follows…
{{ item2.next_page_number }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.