There should be an option to disable the inclusion of query params in the next/previous links in CursorPagination #8461
Unanswered
githubuser88442
asked this question in
Ideas & Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have extended the CursorPagination:
I want the "next"/"previous" links to NOT include query parameters that were used to initially create the pagination cursor:
I don't want the query params that I included myself for the first request (
&date_range=30_days&ordering=-date_added&page=1&page_size=10
) to be included in the final 'next'/'previous' URL.The reason why, is because for some reason, in combination with django_filters/rest_framework.filters, the filters re-calculate the filters for the entire queryset on every pagination IF the query parameters are included.
I made an artificially heavy request that took 70 seconds, but what made no sense to me was that why it takes 70 seconds on every page, instead of just on the first request. Then I tried removing the filtering query params after the cursor in the 'next' url, and suddenly the next page request is instant, and the results are the same.
From what I understand, the extra filtering query params are not necessary after the first request (which calculates the queryset for the pages), so it would be nice if there was an option to not include them.
In the case that they're necessary, they can always be added manually by the user to end of the request anyway, I don't see why they need to be included in the URL automatically. If there is something I'm not realizing in terms of their necessity, would like to know! And if there's already a way to do it, I would really like to know as well, as currently the only way I can imagine is manually parsing the 'next' URL on an external frontend, and only keeping the 'cursor' query param.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions