I am using django-pagination to paginate my object list. It is working flawlessly. I want to give a number to each object on the page and I am using {{forloop.counter}}
for that, but the problem is it starts the object count from 1 on each page. I wanted to display the actual object count.
Say if I am paginating 10 objects per page, then I want to object number as 11 for the first object on page 2. I tried writing a template filter for this, but somehow I am not able to send both request.get.page
and {{forloop.counter}}
to my filter function. I am unable to do it that way.
Any help for direction will be appreciated.
You can use the add
template tag to add the current count from the paginator to the forloop
{{ forloop.counter|add:paginator.page.start_index }}
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