Created
October 22, 2020 23:59
-
-
Save sc2-zobka/cb93107246f9e9fa6f608c80095ee414 to your computer and use it in GitHub Desktop.
Paginator for django apps
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 paginator.num_pages > 1%} | |
| <div class="d-flex justify-content-center"> | |
| <ul class="pagination"> | |
| {% if entity.has_previous %} | |
| <li class="page-item d-none d-sm-block"><a class="page-link" href="?page={{ entity.previous_page_number }}#pagtable">Anterior</a></li> | |
| {% endif %} | |
| {% for page in paginator.page_range %} | |
| {% if forloop.last and page != entity.number and paginator.num_pages > 7 %} | |
| {% if entity.next_page_number != paginator.num_pages%} | |
| <li class="page-item"> | |
| <a class="page-link" href="?page={{ entity.number | add:1}}#pagtable">...</a> | |
| </li> | |
| {% endif %} | |
| <li class="page-item"> | |
| <a class="page-link" href="?page={{paginator.num_pages}}#pagtable">{{paginator.num_pages}}</a> | |
| </li> | |
| {% endif %} | |
| {% if page == entity.number and page > 7 %} | |
| <li class="page-item"> | |
| <a class="page-link" href="?page={{ page | add:-1 }}#pagtable">...</a> | |
| </li> | |
| {% endif %} | |
| {% if page < 7 or page == entity.number %} | |
| <li class="page-item {% if page == entity.number %}active{% endif %}"> | |
| <a class="page-link" href="?page={{ page }}#pagtable">{{ page }}</a> | |
| </li> | |
| {% endif %} | |
| {% endfor %} | |
| {% if entity.has_next %} | |
| <li class="page-item d-none d-sm-block"> | |
| <a class="page-link" href="?page={{ entity.next_page_number }}#pagtable">Siguiente</a> | |
| </li> | |
| {% endif %} | |
| </ul> | |
| </div> | |
| <div class="d-flex justify-content-center d-sm-none"> | |
| {% if entity.has_previous %} | |
| <span class="page-item"><a class="page-link" href="?page={{ entity.previous_page_number }}#pagtable">Anterior</a></span> | |
| {% endif %} | |
| {% if entity.has_next %} | |
| <span class="page-item"><a class="page-link" href="?page={{ entity.next_page_number }}#pagtable">Siguiente</a></span> | |
| {% endif %} | |
| <br> | |
| <br> | |
| </div> | |
| {% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment