django-rest-framework-link-header-pagination
django-rest-framework-link-header-pagination copied to clipboard
Include total count in response
Background
The Link
HTTP header only includes links to different pages. It would be great to also include the total count somewhere in the response.
Potential Solution
This SO answer suggests including an X-Total-Count
header in the response.
I'm happy to work on this if you don't have time to do it.
Workaround
I understand I can calculate this using the following steps but it includes an extra API call:
- Hit the
last
url - Calculate the number of items in the
last
response - Perform the simple calculation:
PAGE_SIZE * (LAST_PAGE_INDEX - 1) + NUM_ITEMS_ON_LAST_PAGE
For example: If I have 25 items with a page size of 10, the calculation would be:
10 * (3 - 1) + 5 = 25
+1
Considering the performance issue, it is suggested to add a setting option to control the on/off switch of this feature.
I am looking forward for a feature like this, when this feature is going to be released ?