A port of ericflo/django-pagination to Python 3 and beyond!
Project description
django-pagination-py3
A port of ericflo/django-pagination to Python 3. Updated to be compatible with Django 4.2 to 6.0.
For versions compatible with Django 3.x and Python 2.7+ please install or download version 1.2.0 from Releases or
Pypi.
Features
- Really easy to use at template level.
- It preserves all request's querystring parameters.
- Settings to customize behavior.
- Translated to fr, de, es, pt, pl and pt_BR.
- A fully working example project.
Installation
Install using pip command:
pip install django-pagination-py3
...or clone the repo and install it using pip:
git clone git://github.com/matagus/django-pagination-py3.git
cd django-pagination-py3
pip install -e .
Add pagination to INSTALLED_APPS in your settings.py:
INSTALLED_APPS = (
# ...
"pagination",
)
Add the middleware:
MIDDLEWARE_CLASSES = (
# ...
'pagination.middleware.PaginationMiddleware',
)
Add this line at the top of your template to load the pagination tags:
{% load pagination_tags %}
Decide on a variable that you would like to paginate, and use the autopaginate tag on that variable before iterating
over it. This could take one of two forms (using the canonical object_list as an example variable):
{% autopaginate object_list %}
This assumes that you would like to have the default 20 results per page. If you would like to specify your own amount of results per page, you can specify that like so:
{% autopaginate object_list 10 %}
Note that this replaces object_list with the list for the current page, so you can iterate over the object_list
like you normally would.
Now you want to display the current page and the available pages, so somewhere after having used autopaginate, use the paginate inclusion tag:
{% paginate %}
This does not take any arguments, but does assume that you have already called autopaginate, so make sure to do so first.
That's it! You have now paginated object_list and given users of the site a way to navigate between the different
pages--all without touching your views.
Running Tests
hatch run test:test will run the tests in every Python + Django versions combination.
hatch run test.py3.14-6.0:test: will run them for python 3.14 and Django 6.0. Please see possible combinations using
hatch env show ("test" matrix).
License
django-pagination-py3 is released under a BSD License - see the LICENSE file for more information.
Acknowledgements
Posts I learned from:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_pagination_py3-2.3.0.tar.gz.
File metadata
- Download URL: django_pagination_py3-2.3.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fc5ee580524f8a60e0151bb5527f16775f5ac13b661de54a6a41f50f600f8f7
|
|
| MD5 |
7f2a08b88c5c8b94a4881c18710dab2c
|
|
| BLAKE2b-256 |
4ca2d05d40bfbbb211b7b970c937e1d73b8bc98fab1b30837eba9db063bdc408
|
File details
Details for the file django_pagination_py3-2.3.0-py2.py3-none-any.whl.
File metadata
- Download URL: django_pagination_py3-2.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d263fb7924101b78cad0184c2e684e77f9199bbf6e50b1168aab377ee8451f00
|
|
| MD5 |
0d5857183a1525aec6e55111733dfce6
|
|
| BLAKE2b-256 |
acce8dd5a269c84caade10d5e5b330bdff05549c846e865eeaaf6c8985f777ac
|