Created
July 20, 2018 15:39
-
-
Save zaemiel/0e7053ef5b135684be9a481b102ef390 to your computer and use it in GitHub Desktop.
Django pagination with bootstrap snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for n in posts.paginator.page_range %} | |
{% if posts.number == n %} | |
<li class="page-item active"> | |
<span class="page-link">{{ n }}<span class="sr-only">(current)</span></span> | |
</li> | |
{% elif n > posts.number|add:'-2' and n < posts.number|add:'2' %} | |
<li class="page-item"><a class="page-link" href="?page={{ n }}">{{ n }}</a></li> | |
{% endif %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment