Django Pagination Links
Project description
Small package for creating a list of page links from a Django paginator object, similar in style to the Django admin - showing the start and end pages, but only showing a limited list of pages in the middle.
Installation
Using pip:
$ pip install django-paginationlinks
Edit your Django project’s settings module, and add paginationlinks:
INSTALLED_APPS = (
# ...
'paginationlinks',
)
Usage
Load the template tag:
{% load pagination_links %}
Typical usage, which shows 1 page on each end, and 1 on each side of the current page:
{% get_pagination_links paginator page_obj as pagination_links %}
However the number of pages on each side can be customised, as well as how many pages at the end - both are optional arguments:
{% get_pagination_links paginator page_obj on_each_side=1 on_ends=2 as pagination_links %}
A more fully featured example for a site:
{% load pagination_links %}
{% if page_obj.has_other_pages %}
{% get_pagination_links paginator page_obj as pagination_links %}
<ul>
{% for page_num in pagination_links %}
{% if page_num.is_current %}
<li class="current">{{ page_num.number }}</li>
{% elif page_num.is_filler %}
<li class="filler">—</li>
{% else %}
<li><a href="?page={{ page_num.number }}">{{ page_num.number }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-paginationlinks-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83c16b2b060be18bdf306372c66c589fe8f86fd237f5ace90cef463b20bd3caa |
|
MD5 | 7eb46f9f46b657b9a5cca4928fc508d6 |
|
BLAKE2b-256 | a9e273c08193cf043dc5a61c40f4f42dd91e7889f8620c31aa0854419d1c4b4c |