rodrigobertin
3/18/2020 - 1:19 PM

Paginator django HTML template

Paginator django HTML template

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <ul class="pagination pull-right">
          {% if page_obj.has_previous %}
            <li>
              {% comment %}<a href="?page=1">&laquo; first</a>{% endcomment %}
              <a href="?page={{ page_obj.previous_page_number }}" class="primary-bg"><i class="fa fa-chevron-left"></i></a>
            </li>
          {% endif %}

          <li class="current">
            <a href="#!">Pagina {{ page_obj.number }} de {{ page_obj.paginator.num_pages }}.</a>
          </li>

          {% if page_obj.has_next %}
            <li>
              <a href="?page={{ page_obj.next_page_number }}" class=""><i class="fa fa-chevron-right"></i></a>
              {% comment %}<a href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a>{% endcomment %}
            </li>
          {% endif %}
        </ul>
      </div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
  <ul class="pagination pull-right">
    {% if page_obj.has_previous %}
      <li>
        <a href="?page=1{% for key,val in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ val }}{% endif %}{% endfor %}" class="btn btn-default btn-sm"><i class="fa fa-chevron-left"></i><i class="fa fa-chevron-left"></i></a>
        <a href="?page={{ page_obj.previous_page_number }}{% for key,val in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ val }}{% endif %}{% endfor %}" class="btn btn-default btn-sm"><i class="fa fa-chevron-left"></i></a>
      </li>
    {% endif %}

    <li class="current">
      <a href="#!" class="btn btn-default btn-sm">Pagina {{ page_obj.number }} de {{ page_obj.paginator.num_pages }}.</a>
    </li>

    {% if page_obj.has_next %}
      <li>
        <a href="?page={{ page_obj.next_page_number }}{% for key,val in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ val }}{% endif %}{% endfor %}" class="btn btn-default btn-sm"><i class="fa fa-chevron-right"></i></a>
        <a href="?page={{ page_obj.paginator.num_pages }}{% for key,val in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ val }}{% endif %}{% endfor %}" class="btn btn-default btn-sm"><i class="fa fa-chevron-right"></i><i class="fa fa-chevron-right"></i></a>
      </li>
    {% endif %}
  </ul>
</div>