Created
September 18, 2020 21:23
-
-
Save rhenter/d2aea29d578f80fd117be1ec983cbfa0 to your computer and use it in GitHub Desktop.
Includes de Paginação e busca para Django usando Bootstrap
This file contains 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
{% load i18n %} | |
<div class="card-tools"> | |
<form class="form-inline" action="." method="GET"> | |
<div class="input-group input-group-sm" style="margin-left: 20px;"> | |
<label for="id_paginate" style="margin-right: 5px;">{% trans "Show" %}</label> | |
<select class="form-control" name="paginate_by" id="id_paginate" onchange="this.form.submit()"> | |
{% for pages in range_pagination %} | |
{% if paginate_by == pages %} | |
<option selected="selected">{{ pages }}</option> | |
{% else %} | |
<option>{{ pages }}</option> | |
{% endif %} | |
{% endfor %} | |
</select> | |
</div> | |
</form> | |
</div> |
This file contains 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
{% load i18n %} | |
{% load l10n %} | |
<div class="card-tools"> | |
<form class="form-inline" action="." method="GET"> | |
<div class="input-group input-group-sm" style="width: 350px;"> | |
<input | |
id="id_search" | |
name="search" | |
type="search" | |
placeholder="{{ placeholder }}" | |
value="{% if search %}{{ search }}{% endif %}" | |
class="form-control float-right"> | |
<div class="input-group-append"> | |
{% if search %} | |
<a id="btn-clear" class="btn btn-default" href="{{ page_base_url }}" title="{% trans 'Clear' %}"> | |
<i class="fa fa-times-circle" aria-hidden="true"></i> | |
</a> | |
{% endif %} | |
<button type="submit" class="btn btn-default"><i class="fas fa-search"></i></button> | |
</div> | |
</div> | |
</form> | |
</div> | |
This file contains 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
{% load i18n %} | |
{% load l10n %} | |
<span> | |
{{ page_obj.number }} {% trans 'of' %} {{ paginator.num_pages }} | |
{% trans 'page' %}{% if paginator.num_pages > 1 %}s{% endif %}. | |
</span> | |
{% if paginator.num_pages > 1 %} | |
<ul class="pagination pagination-sm m-0 float-right"> | |
{% if page_obj.has_previous %} | |
<li class="page-item"> | |
<a class="page-link" href="?page={{ page_obj.previous_page_number }}"> | |
<i class="fas fa-chevron-left"></i> | |
</a> | |
</li> | |
{% else %} | |
<li class="page-item disabled"> | |
<a class="page-link disabled" href="#"> | |
<i class="fas fa-chevron-left"></i> | |
</a> | |
</li> | |
{% endif %} | |
{% if page_obj.number|add:'-4' > 1 %} | |
<li class="page-item"> | |
<a class="page-link" href="{{ search_url }}{{ append_param }}page=1">1</a> | |
</li> | |
<li class="page-item"> | |
<a class="page-link" href="{{ search_url }}{{ append_param }}page={{ page_obj.number|add:'-5' }}">…</a> | |
</li> | |
{% endif %} | |
{% for i in paginator.page_range %} | |
{% if page_obj.number == i %} | |
<li class="page-item active"><a class="page-link" href="#">{{ i }}</a></li> | |
{% elif i > page_obj.number|add:'-5' and i < page_obj.number|add:'5' %} | |
<li class="page-item"><a class="page-link" href="?page={{ i }}">{{ i }}</a></li> | |
{% endif %} | |
{% endfor %} | |
{% if paginator.num_pages > page_obj.number|add:'4' %} | |
<li class="page-item"> | |
<a class="page-link" href="{{ search_url }}{{ append_param }}page={{ page_obj.number|add:'5' }}">…</a> | |
</li> | |
<li class="page-item"> | |
<a class="page-link" | |
href="{{ search_url }}{{ append_param }}page={{ paginator.num_pages }}">{{ paginator.num_pages }}</a> | |
</li> | |
{% endif %} | |
{% if page_obj.has_next %} | |
<li class="page-item"> | |
<a class="page-link" href="?page={{ page_obj.next_page_number }}"> | |
<i class="fas fa-chevron-right"></i> | |
</a> | |
</li> | |
{% else %} | |
<li class="page-item disabled"> | |
<a class="page-link" href="#"> | |
<i class="fas fa-chevron-right"></i> | |
</a> | |
</li> | |
{% endif %} | |
</ul> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment