Limit paginator links to next and previous two pages.

This commit is contained in:
Christopher Charbonneau Wells 2017-09-17 08:46:35 -04:00
parent ab1b9ee7a8
commit 8f9a756fa2
1 changed files with 5 additions and 3 deletions

View File

@ -12,9 +12,11 @@
{% endif %}
{% for num in page_obj.paginator.page_range %}
<li class="page-item{% if num == page_obj.number %} active{% endif %}">
<a class="page-link" href="?page={{ num }}">{{ num }}</a>
</li>
{% if num > page_obj.number|add:"-3" and num < page_obj.number|add:"3" %}
<li class="page-item{% if num == page_obj.number %} active{% endif %}">
<a class="page-link" href="?page={{ num }}">{{ num }}</a>
</li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}