I use the code from the documentation to paginate 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 a 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's a bug here: when the url contains a query string and one clicks on the Pager, the original query string gets lost. For example:
example.com?var1=33&var2=44
and then when one clicks on "page2", the url becomes
example.com?page=2 # var1=33&var2=44 is lost
instead of:
example.com?var1=33&var2=44&page=2
I haven't found neither the standard, nor easy way to fix it. How can I do that?
UPDATE:
of course, the names of the parameters, their values and whether they exist or not is not known.