Show page items count in django pagination

Viewed 21308

I'm trying to figure out how to show something like "Showing 1-10 of 52" using django pagination in my templates.

I accomplished the pagination itself but nothing comes to my mind about this requirement.
Any ideas?

5 Answers
paginator = Paginator(query, settings.SEARCH_DATA_PER_PAGE)

For number of Pages :

num_of_pages = paginator.num_pages

For total number of items across all pages :

num_of_objects = paginator.count

You can calculate number of items per page from this data.

Related