forked from ericflo/django-pagination
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from matagus/readme-and-more-translations
Improved readme file and more translations
- Loading branch information
Showing
8 changed files
with
189 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,117 @@ | ||
django-pagination-py3 | ||
===================== | ||
==================== | ||
|
||
A port of django-pagination to Python 3, also compatible with Python 2.x ;) | ||
![Python Compatibility](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue.svg) [![PyPi Version](https://img.shields.io/pypi/v/django-pagination-py3.svg)](https://pypi.python.org/pypi/django-pagination-py3) ![CI badge](https://github.com/matagus/django-pagination-py3/actions/workflows/ci.yml/badge.svg) [![codecov](https://codecov.io/gh/matagus/django-pagination-py3/graph/badge.svg?token=a64SxEDQk0)](https://codecov.io/gh/matagus/django-pagination-py3) [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) | ||
|
||
A port of [ericflo/django-pagination](https://github.com/ericflo/django-pagination) to Python 3. Updated to be compatible with Django 4.x and 5.0. | ||
|
||
For versions compatible with Django 3.x and Python 2.7+ please install or download version `1.2.0` from [Releases](https://github.com/matagus/django-pagination-py3/releases) or | ||
[Pypi](https://pypi.org/project/django-pagination-py3/). | ||
|
||
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: | ||
|
||
```bash | ||
pip install django-pagination-py3 | ||
``` | ||
|
||
...or clone the repo and install it using `pip`: | ||
|
||
```bash | ||
git clone git://github.com/matagus/django-pagination-py3.git | ||
cd django-pagination-py3 | ||
pip install -e . | ||
``` | ||
|
||
Add `pagination` INSTALLED_APPS to your `settings.py`: | ||
|
||
```python | ||
INSTALLED_APPS = ( | ||
# ... | ||
"pagination", | ||
) | ||
``` | ||
|
||
Add the middleware: | ||
|
||
```python | ||
MIDDLEWARE_CLASSES = ( | ||
# ... | ||
'pagination.middleware.PaginationMiddleware', | ||
) | ||
``` | ||
|
||
Add this line at the top of your template to load the pagination tags: | ||
|
||
```html | ||
{% 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): | ||
|
||
```html | ||
{% 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: | ||
|
||
```html | ||
{% 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: | ||
|
||
```html | ||
{% 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.12-5.0:test`: will run them for python 3.12 and Django 5.0. Please see possible combinations using | ||
`hatch env show` ("test" matrix). | ||
|
||
|
||
Install it from pypi.python.org: | ||
License | ||
======= | ||
|
||
pip install django-pagination-py3 | ||
`django-pagination-py3` is released under an BSD License - see the `LICENSE` file for more information. | ||
|
||
or just clone this repository and run: | ||
|
||
python setup.py install | ||
Acknowledgements | ||
================ | ||
|
||
Develop & built using [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![code style - black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | ||
|
||
Usage | ||
----- | ||
Posts I learned from: | ||
|
||
Use it the same way you use django-pagination. | ||
- [Switching to Hatch](https://andrich.me/2023/08/switching-to-hatch/) | ||
- [Automate Hatch Publish with GitHub Actions](https://blog.pecar.me/automate-hatch-publish) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = "1.2.0" | ||
version = "2.0.0" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2009-03-16 16:26+0100\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
#: templates/pagination/pagination.html:5 | ||
#: templates/pagination/pagination.html:7 | ||
msgid "previous" | ||
msgstr "předchozí" | ||
|
||
#: templates/pagination/pagination.html:21 | ||
#: templates/pagination/pagination.html:23 | ||
msgid "next" | ||
msgstr "další" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# django-pagination Spanish translation | ||
# Copyright (C) 2010, Miguel Araujo | ||
# This file is distributed under the same license as the django-pagination package. | ||
# Miguel Araujo <[email protected]>, 2010 | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2010-09-16 16:32+0200\n" | ||
"PO-Revision-Date: 2010-09-16 16:38+0200\n" | ||
"Last-Translator: Miguel Araujo <[email protected]>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
||
#: templates/pagination/pagination.html:5 | ||
#: templates/pagination/pagination.html:7 | ||
msgid "previous" | ||
msgstr "anterior" | ||
|
||
#: templates/pagination/pagination.html:21 | ||
#: templates/pagination/pagination.html:23 | ||
msgid "next" | ||
msgstr "siguiente" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# django-pagination in Portuguese (Brazil). | ||
# Copyright (C) 2011, Tiago Samaha Cordeiro | ||
# This file is distributed under the same license as the django-pagination package. | ||
# Tiago Samaha Cordeiro <[email protected]>, 2011. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: 1.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2011-01-16 22:06-0200\n" | ||
"PO-Revision-Date: 2011-01-16 22:15-3\n" | ||
"Last-Translator: Tiago Samaha Cordeiro <[email protected]>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"Language: Portuguese Brazil\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
||
#: templates/pagination/pagination.html:5 | ||
#: templates/pagination/pagination.html:7 | ||
msgid "previous" | ||
msgstr "anterior" | ||
|
||
#: templates/pagination/pagination.html:21 | ||
#: templates/pagination/pagination.html:23 | ||
msgid "next" | ||
msgstr "próximo" |