I use the code from the documentation to break the data:
try: data = paginator.page(request.GET.get('page')) except PageNotAnInteger: page = 1 data = paginator.page(1) except EmptyPage: data = paginator.page(paginator.num_pages)
And the page:
<div class="pagination"> <span class="step-links"> {% if data.has_previous %} <a href="?page={{ data.previous_page_number }}">previous</a> {% endif %} <span class="current"> <b>Page</b> {{ data.number }} of {{ data.paginator.num_pages }} </span> {% if data.has_next %} <a href="?page={{ data.next_page_number }}">next</a> {% endif %} </span> </div>
But there is an error: when the url contains the query string and one click on the Pager, the original query string is lost. For instance:
example.com?var1=33&var2=44
and then when you click "page2", the URL becomes
example.com?page=2
instead:
example.com?var1=33&var2=44&page=2
I did not find a standard or easy way to fix it. How can i do this?
UPDATE:
Of course, the names of the parameters, their values and whether they exist or not are unknown.
user266003
source share