Skip to content

Instantly share code, notes, and snippets.

@gustavcaves
Forked from hcosta/pagination.html
Created March 23, 2021 19:40
Show Gist options
  • Save gustavcaves/ee08435e472981b1d89c34b3325be1e2 to your computer and use it in GitHub Desktop.
Save gustavcaves/ee08435e472981b1d89c34b3325be1e2 to your computer and use it in GitHub Desktop.
Menú de paginación con Bootstrap 4 para ListView en Django
<!-- Menú de paginación -->
{% if is_paginated %}
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item ">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}">&laquo;</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">&laquo;</a>
</li>
{% endif %}
{% for i in paginator.page_range %}
<li class="page-item {% if page_obj.number == i %}active{% endif %}">
<a class="page-link" href="?page={{ i }}">{{ i }}</a>
</li>
{% endfor %}
{% if page_obj.has_next %}
<li class="page-item ">
<a class="page-link" href="?page={{ page_obj.next_page_number }}">&raquo;</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">&raquo;</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment