Skip to content

Instantly share code, notes, and snippets.

@erickgnavar
Created December 14, 2012 04:56
Show Gist options
  • Save erickgnavar/4282778 to your computer and use it in GitHub Desktop.
Save erickgnavar/4282778 to your computer and use it in GitHub Desktop.
Django pagination with bootstrap
{% load common_tags %}
<!--Pagination-->
<div class="pagination pagination-centered">
<ul>
{% if page_obj.has_previous %}
<li><a href="?page={{ page_obj.previous_page_number }}">«</a></li>
{% else %}
<li class="disabled"><a href="">«</a></li>
{% endif %}
{% for page_number in page_obj.paginator.num_pages|to_range %}
{% if page_number == page_obj.number %}
<li class="active"><a href="?page={{ page_obj.number }}">{{ page_number }}</a></li>
{% else %}
<li><a href="?page={{ page_number }}">{{ page_number }}</a></li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li><a href="?page={{ page_obj.next_page_number }}">»</a></li>
{% else %}
<li class="disabled"><a href="">»</a></li>
{% endif %}
</ul>
</div>
<!--End Pagination-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment