Skip to content

Commit

Permalink
Fixes issue with pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
jlariza committed May 7, 2024
1 parent 16857ef commit 3d4d48c
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ <h2>Search your pokemon</h2>
</ul>
</td>
</tr>
{% empty %}
<tr>
<th scope="row">No Results found!</th>
</tr>
{% endfor %}
</tbody>
</table>
Expand All @@ -60,23 +64,24 @@ <h2>Search your pokemon</h2>
<ul class="pagination">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?page=1">&laquo; first</a>
<a class="page-link"
href="?page=1&{% for key,value in request.GET.items %}{% if key != 'page' %}{{key}}={{value}}&{% endif %}{% endfor %}">&laquo; first</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}">previous</a>
<a class="page-link" href="?page={{ page_obj.previous_page_number }}&{% for key,value in request.GET.items %}{% if key != 'page' %}{{key}}={{value}}&{% endif %}{% endfor %}">previous</a>
</li>
{% endif %}
{% for page in page_obj.paginator.page_range %}
<li class="page-item {% if page_obj.number == page %}active{% endif %}">
<a class="page-link" href="?page={{ page }}">{{ page }}</a>
<a class="page-link" href="?page={{ page }}&{% for key,value in request.GET.items %}{% if key != 'page' %}{{key}}={{value}}&{% endif %}{% endfor %}">{{ page }}</a>
</li>
{% endfor %}
{% if page_obj.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.next_page_number }}">next</a>
<a class="page-link" href="?page={{ page_obj.next_page_number }}&{% for key,value in request.GET.items %}{% if key != 'page' %}{{key}}={{value}}&{% endif %}{% endfor %}">next</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a>
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}&{% for key,value in request.GET.items %}{% if key != 'page' %}{{key}}={{value}}&{% endif %}{% endfor %}">last &raquo;</a>
</li>
{% endif %}
</ul>
Expand Down

0 comments on commit 3d4d48c

Please sign in to comment.