Reputation: 217
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
Upvotes: 3
Views: 1979
Reputation: 48317
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 %}
Upvotes: 7