I want to display the item number with the items in a page using django paginator.
I want to display the item number in front of item in a page for example:
If i have total 15 items and my paginator code display 10 items per page then on first page it should display like:
1 item1
2 item2
etc
and next page it should display:
11 item11
12 item12
etc
If you use generic django views with pagination, you have page_obj, and following will do the trick:
{% for object in object_list %}
{{forloop.counter|add:page_obj.start_index }}
{% endfor %}
Moreover, if starting from index 1 is critical, try this instead:
{% for object in object_list %}
{{forloop.counter0|add:page_obj.start_index }}
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With