I am using a Django Paginator and I want to have multiple available get parameters, such as: page=1 sort_by=price
However, in my template tags I have:
Showing items sorted by {{ SORT_PARAM }}.
Showing {{ ITEMS_PER_PAGE }} items per page.
{% if has_prev %}
<a href="?page={{ prev_page }}">Previous</a> |
{% endif %}
However, this does not preserve the other GET variables. What I mean is, if I'm viewing
page/?page=1&sort_by=price
and I click the link in the template fragment above, I will go to
page=2
instead of
page=2&sort_by=price
What I mean is, the a href does not preserve the other GET parameters.
One solution is I could type all the possible GET parameters in the a href, such as
<a href="?page={{ prev_page }}&items_per_page={{ ITEMS_PER_PAGE }}&sort_param={{ SORT_PARAM }}">Previous</a>
but this will become less scalable the more arguments I want to add to my browsing. I'm guessing there should be an automated way to obtain all GET parameters, and then pass those and one more?