Login

Django Twitter Bootstrap 3 pagination

Author:
Ragnar_Lodbrok
Posted:
February 2, 2014
Language:
Python
Version:
1.6
Tags:
pagination bootstrap
Score:
3 (after 3 ratings)

Twitter Bootstrap 3 default pagination with all pages indexes and controls for Django 1.6 ListView template.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
{% if is_paginated %}
        <ul class="pagination pagination-centered">
            {% if page_obj.has_previous %}
                <li><a href="?page=1"><<</a></li>
                <li><a href="?page={{ page_obj.previous_page_number }}"><</a></li>
            {% endif %}

            {% for i in paginator.page_range %}
                <li {% if page_obj.number == i %} class="active" {% endif %}><a href="?page={{i}}">{{i}}</a></li>
            {% endfor %}

            {% if page_obj.has_next %}
                <li><a href="?page={{ page_obj.next_page_number }}">></a></li>
                <li><a href="?page={{ page_obj.paginator.num_pages }}">>></a></li>
            {% endif %}
        </ul>
    {% endif %}

More like this

  1. Django-pagination with Bootstrap CSS by ronbeltran 3 years, 3 months ago
  2. Custom Form Example: Forms for Bootstrap Html - CSS Toolkit by fatiherikli 3 years, 8 months ago
  3. cron/console bootstrap django by nstrite 8 years ago
  4. Simple Paginator Function by goodsanket 5 years, 7 months ago
  5. Pagination Template Tag by ioan1k 5 years, 11 months ago

Comments

danilchenko (on November 30, 2014):

You shouldn't use ">" and "<" symbols in HTML. Replace it with "[HTML_REMOVED]" and "[HTML_REMOVED]" respectively.

#

danilchenko (on November 30, 2014):

& raquo; AND & laquo;

#

iewgnaw (on December 25, 2014):

if page_range is large, it would be awful

#

tgdn (on April 10, 2015):

Maybe check something I built to help out https://github.com/tgdn/django-bootstrap-pagination

#

Please login first before commenting.