M
M
Mat1lda2020-06-04 15:18:19
Django
Mat1lda, 2020-06-04 15:18:19

Django filtering on get parameters on page change?

Actually the question is, I do filtering by passing parameters to get, but the trouble is that they are not saved on the new page, and after ? just page=. Actually, is there a way to save filters during pagination????

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2020-06-11
@pyHammer

There is a good django-spurl plugin called, specifically for pagination, I apply it like this

{% load spurl %}
<a href="{% spurl path=request.get_full_path query=request.GET set_query="page={{ page }}" %}">{{ page }}</a>

What happens here is, first I fill the entire query with the current GET request parameters, and in set_query I just change the current page to the one I need.
Works just perfect, all filters are saved

A
alternativshik, 2020-06-05
@alternativshik

Nothing prevents you from passing all those get parameters to the template and inserting them into the paginator links.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question