- Author:
- Ragnar_Lodbrok
- Posted:
- February 2, 2014
- Language:
- Python
- Version:
- 1.6
- Score:
- 4 (after 4 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
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
You shouldn't use ">" and "<" symbols in HTML. Replace it with "»" and "«" respectively.
#
& raquo; AND & laquo;
#
if page_range is large, it would be awful
#
Maybe check something I built to help out https://github.com/tgdn/django-bootstrap-pagination
#
Please login first before commenting.