Skip to main content

django-cool-pagination

Build Status Coverage Status PyPI version

django-cool-pagination is simple pagination app that saves your time.

WARNING:

The project is still on development stage, some things may not work properly.

Prerequisites

Currently it supports Bootstrap 4.x only. So that you have to add Bootstrap4 to your project.

Features

paris
  • Dynamic query string creation
  • Length auto control
  • Fully customizable (aspiring)

Installation

Installing

pip

pip install django-cool-pagination

setup.py

git clone https://github.com/joe513/django-cool-pagination.git
cd django-cool-pagination
python setup.py install

Setting up

Add to INSTALLED_APPS

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    'django_cool_paginator'

Make sure request is in context_processors

    'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',

Using

View

FBV (Function based view)

def listing(request):
    contact_list = Contacts.objects.all()
    paginator = Paginator(contact_list, 25)

    page = request.GET.get('page')
    page_obj = paginator.get_page(page)
    return render(request, 'list.html', {'page_obj': page_obj})

CBV (Class based view)

class Listing(ListView):
    model = Item
    paginate_by = 5

Template

{% load cool_paginate %}

{% for contact in page_obj %}
    ...
{% endfor %}

{% cool_paginate page_obj=ENTER HERE YOUR PAGE OBJECT! %}

Note: You don't have to specify page if its name is page_obj as default.

Customization

You can customize it so that it works as you want. Customize it by defining settings either in setting.py or inside of {% cool_paginate %}

setting.py

COOL_PAGINATOR_NEXT_NAME - Name for "next" button in pagination bar.
COOL_PAGINATOR_PREVIOUS_NAME - Name for "previous" button in pagination bar
COOL_PAGINATOR_SIZE - Size of pagination bar (choose: "LARGE" or "SMALL")
COOL_PAGINATOR_ELASTIC - What page width is elastic mode enabled from?

{% cool_paginate page_obj next_name previous_name size elastic %}

page_obj - Type here your page object.
next_name - Name for "next" button in pagination bar.
previous_name - Name for "previous" button in pagination bar
size - Size of pagination bar (choose: "LARGE" or "SMALL")
elastic - What page width is elastic mode enabled from?

Note: {% cool_paginate %} has a priority, django-cool-pagination will firstly look at this, after at setting.py

License

This project is licensed under the MIT License - see the LICENSE file for details


inspired by inoks/m3u8

Metadata

Release files for django-cool-pagination 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cool-pagination 0.3.0
File Size Uploaded Provenance
django-cool-pagination-0.3.0.tar.gz 7.3 kB Without provenance Details

Release files / django-cool-pagination-0.3.0.tar.gz

Download URL django-cool-pagination-0.3.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bdafc0d9e661f1d39348c05d9874b82af8d2274696f1e5ba1cb880461b736476
BLAKE2b-256 checksum
How to use checksums
df3ff4d24622d5b7c57e8cff246cf6052e7f51a1f985d9bb4f574fb3a533e107
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-cool-pagination 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page