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 %} {% endif %}
{% for num in page_obj.paginator.page_range %} {% for num in page_obj.paginator.page_range %}
{% 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 %}"> <li class="page-item{% if num == page_obj.number %} active{% endif %}">
<a class="page-link" href="?page={{ num }}">{{ num }}</a> <a class="page-link" href="?page={{ num }}">{{ num }}</a>
</li> </li>
{% endif %}
{% endfor %} {% endfor %}
{% if page_obj.has_next %} {% if page_obj.has_next %}