Skip to content

Instantly share code, notes, and snippets.

@augustogoulart
Created May 4, 2017 18:10
Show Gist options
  • Select an option

  • Save augustogoulart/e947b141c915530ce176e0f1c216c1d2 to your computer and use it in GitHub Desktop.

Select an option

Save augustogoulart/e947b141c915530ce176e0f1c216c1d2 to your computer and use it in GitHub Desktop.
Django pagination with bootstrap classes
<ul class="pagination">
{% if page.has_previous %}
<li><a href="?page={{ page.previous_page_number }}"><span>&laquo;</span></a></li>
{% else %}
<li class="disabled"><span>&laquo;</span></li>
{% endif %}
{% for i in paginator.page_range %}
{% if page.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.has_next %}
<li><a href="?page={{ page_obj.next_page_number }}">&raquo;</a></li>
{% else %}
<li class="disabled"><span>&raquo;</span></li>
{% endif %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment