Created
January 10, 2016 20:09
-
-
Save nnewman/e96b6389a8ff8161dca3 to your computer and use it in GitHub Desktop.
Template code for adding pagination to a Django template with bootstrap3 styling
This file contains hidden or 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
| {% if is_paginated %} | |
| <nav> | |
| <ul class="pagination"> | |
| {% if page_obj.has_previous %} | |
| <li><a href="?page={{ page_obj.previous_page_number }}">{% if not page_obj.has_previous %}<span aria-hidden="true">{% endif %}« Previous</span><span class="sr-only">Previous</span></a></li> | |
| {% endif %} | |
| {% for page in paginator.page_range %} | |
| <li {% if page_obj.number == forloop.counter %}class="active"{% endif %}><a href="?page={{forloop.counter}}">{{forloop.counter}}</a></li> | |
| {% endfor %} | |
| {% if page_obj.has_next %} | |
| <li><a href="?page={{ page_obj.next_page_number }}">{% if not page_obj.has_next %}<span aria-hidden="true">{% endif %}Next »</span><span class="sr-only">Next</span></a></li> | |
| {% endif %} | |
| </ul> | |
| </nav> | |
| {% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment