-
-
Save ErickMwazonga/3a404bf9a02a0cb55fe0409e308e4434 to your computer and use it in GitHub Desktop.
Django Bootstrap Pagination Widget
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
<table class="table table-bordered"> | |
<thead> | |
<tr> | |
<th>Title</th> | |
<th>Author</th> | |
<th>Date</th> | |
</tr> | |
</thead> | |
<tbody> | |
{% for article in articles %} | |
<tr> | |
<td>{{ article.title }}</td> | |
<td>{{ article.author }}</td> | |
<td>{{ article.date }}</td> | |
</tr> | |
{% endfor %} | |
</tbody> | |
</table> | |
{% include 'paginator.html' with page_obj=articles %} |
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
<ul class="pagination"> | |
{% if page_obj.has_previous %} | |
<li><a href="?page={{ page_obj.previous_page_number }}">«</a></li> | |
{% else %} | |
<li class="disabled"><span>«</span></li> | |
{% endif %} | |
{% for i in page_obj.paginator.page_range %} | |
{% if page_obj.number == i %} | |
<li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li> | |
{% else %} | |
<li><a href="?page={{ i }}">{{ i }}</a></li> | |
{% endif %} | |
{% endfor %} | |
{% if page_obj.has_next %} | |
<li><a href="?page={{ page_obj.next_page_number }}">»</a></li> | |
{% else %} | |
<li class="disabled"><span>»</span></li> | |
{% endif %} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment