[Answer]-Django Conflict between 2 pagination

1👍

First off, your variable names versus how you describe everything is quite confusing.

The issue is you are using two different variables for the page: n for person (or comment) and page for house (or posts). In each of your <a href=""> you need to set both n and page not just one. So:

<a class="Link" href= "{% if formula %}?text={{formula}}&{% else %}?{% endif %}page={{ posts.previous_page_number }}&n={{ comment.number }}">newer entries &lt;&lt; </a>
<a class="Link" href="{% if formula %}?text={{formula}}&{% else %}?{% endif %}page={{ posts.next_page_number }}&n={{ comment.number }}"> &gt;&gt; older entries</a>

<a class="Link" href= "?n={{ comment.previous_page_number }}&page={{ posts.number }}">newer entries &lt;&lt; </a>
<a class="Link" href="?n={{ comment.next_page_number }}&page={{ posts.number }}"> &gt;&gt; older entries</a>

0👍

In the same view you change the value of paginator two times

paginator = Paginator(comment, 5)

# here you have code that does stuff and some lines below

paginator = Paginator(posts, 5)

if you want two paginators in the same view you should also name them differently (and add them to your context variables)

Something I can suggest is to have an ajax pagination view that you’re going to call to switch between pages in your templates. In this way, you can change page to each resultset separately without needing to reload the entire view (and probably loosing your pagination state)

Leave a comment