Skip to content

Commit bea9a32

Browse files
authored
Merge pull request #12 from matagus/readme-and-more-translations
Improved readme file and more translations
2 parents 0a673f1 + 4caa657 commit bea9a32

File tree

8 files changed

+189
-11
lines changed

8 files changed

+189
-11
lines changed

README.md

Lines changed: 105 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,117 @@
11
django-pagination-py3
2-
=====================
2+
====================
33

4-
A port of django-pagination to Python 3, also compatible with Python 2.x ;)
4+
![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)
5+
6+
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.
7+
8+
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
9+
[Pypi](https://pypi.org/project/django-pagination-py3/).
10+
11+
Features
12+
========
13+
14+
- Really easy to use at template level.
15+
- It preserves all request's querystring parameters.
16+
- Settings to customize behavior.
17+
- Translated to fr, de, es, pt, pl and pt_BR.
18+
- A fully working example project.
519

620

721
Installation
8-
------------
22+
============
23+
24+
Install using `pip` command:
25+
26+
```bash
27+
pip install django-pagination-py3
28+
```
29+
30+
...or clone the repo and install it using `pip`:
31+
32+
```bash
33+
git clone git://github.com/matagus/django-pagination-py3.git
34+
cd django-pagination-py3
35+
pip install -e .
36+
```
37+
38+
Add `pagination` INSTALLED_APPS to your `settings.py`:
39+
40+
```python
41+
INSTALLED_APPS = (
42+
# ...
43+
"pagination",
44+
)
45+
```
46+
47+
Add the middleware:
48+
49+
```python
50+
MIDDLEWARE_CLASSES = (
51+
# ...
52+
'pagination.middleware.PaginationMiddleware',
53+
)
54+
```
55+
56+
Add this line at the top of your template to load the pagination tags:
57+
58+
```html
59+
{% load pagination_tags %}
60+
```
61+
62+
Decide on a variable that you would like to paginate, and use the autopaginate tag on that variable before iterating
63+
over it. This could take one of two forms (using the canonical `object_list` as an example variable):
64+
65+
```html
66+
{% autopaginate object_list %}
67+
```
68+
69+
This assumes that you would like to have the default 20 results per page. If you would like to specify your own amount
70+
of results per page, you can specify that like so:
71+
72+
```html
73+
{% autopaginate object_list 10 %}
74+
```
75+
76+
Note that this replaces ``object_list`` with the list for the current page, so you can iterate over the `object_list`
77+
like you normally would.
78+
79+
80+
Now you want to display the current page and the available pages, so somewhere after having used autopaginate, use the
81+
paginate inclusion tag:
82+
83+
```html
84+
{% paginate %}
85+
```
86+
87+
This does not take any arguments, but does assume that you have already called autopaginate, so make sure to do so first.
88+
89+
90+
That's it! You have now paginated `object_list` and given users of the site a way to navigate between the different
91+
pages--all without touching your views.
92+
93+
94+
Running Tests
95+
-------------
96+
97+
`hatch run test:test` will run the tests in every Python + Django versions combination.
98+
99+
`hatch run test.py3.12-5.0:test`: will run them for python 3.12 and Django 5.0. Please see possible combinations using
100+
`hatch env show` ("test" matrix).
101+
9102

10-
Install it from pypi.python.org:
103+
License
104+
=======
11105

12-
pip install django-pagination-py3
106+
`django-pagination-py3` is released under an BSD License - see the `LICENSE` file for more information.
13107

14-
or just clone this repository and run:
15108

16-
python setup.py install
109+
Acknowledgements
110+
================
17111

112+
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)
18113

19-
Usage
20-
-----
114+
Posts I learned from:
21115

22-
Use it the same way you use django-pagination.
116+
- [Switching to Hatch](https://andrich.me/2023/08/switching-to-hatch/)
117+
- [Automate Hatch Publish with GitHub Actions](https://blog.pecar.me/automate-hatch-publish)

pagination/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "1.2.0"
1+
version = "2.0.0"
441 Bytes
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3+
# This file is distributed under the same license as the PACKAGE package.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5+
#
6+
#, fuzzy
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: PACKAGE VERSION\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2009-03-16 16:26+0100\n"
12+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14+
"Language-Team: LANGUAGE <LL@li.org>\n"
15+
"MIME-Version: 1.0\n"
16+
"Content-Type: text/plain; charset=UTF-8\n"
17+
"Content-Transfer-Encoding: 8bit\n"
18+
19+
#: templates/pagination/pagination.html:5
20+
#: templates/pagination/pagination.html:7
21+
msgid "previous"
22+
msgstr "předchozí"
23+
24+
#: templates/pagination/pagination.html:21
25+
#: templates/pagination/pagination.html:23
26+
msgid "next"
27+
msgstr "další"
503 Bytes
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# django-pagination Spanish translation
2+
# Copyright (C) 2010, Miguel Araujo
3+
# This file is distributed under the same license as the django-pagination package.
4+
# Miguel Araujo <miguel.araujo.perez@gmail.com>, 2010
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: PACKAGE VERSION\n"
9+
"Report-Msgid-Bugs-To: \n"
10+
"POT-Creation-Date: 2010-09-16 16:32+0200\n"
11+
"PO-Revision-Date: 2010-09-16 16:38+0200\n"
12+
"Last-Translator: Miguel Araujo <miguel.araujo.perez@gmail.com>\n"
13+
"Language-Team: LANGUAGE <LL@li.org>\n"
14+
"MIME-Version: 1.0\n"
15+
"Content-Type: text/plain; charset=UTF-8\n"
16+
"Content-Transfer-Encoding: 8bit\n"
17+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
18+
19+
#: templates/pagination/pagination.html:5
20+
#: templates/pagination/pagination.html:7
21+
msgid "previous"
22+
msgstr "anterior"
23+
24+
#: templates/pagination/pagination.html:21
25+
#: templates/pagination/pagination.html:23
26+
msgid "next"
27+
msgstr "siguiente"
515 Bytes
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# django-pagination in Portuguese (Brazil).
2+
# Copyright (C) 2011, Tiago Samaha Cordeiro
3+
# This file is distributed under the same license as the django-pagination package.
4+
# Tiago Samaha Cordeiro <tiagosamaha@gmail.com>, 2011.
5+
#
6+
#, fuzzy
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: 1.0\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2011-01-16 22:06-0200\n"
12+
"PO-Revision-Date: 2011-01-16 22:15-3\n"
13+
"Last-Translator: Tiago Samaha Cordeiro <tiagosamaha@gmail.com>\n"
14+
"Language-Team: LANGUAGE <LL@li.org>\n"
15+
"Language: Portuguese Brazil\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
20+
21+
#: templates/pagination/pagination.html:5
22+
#: templates/pagination/pagination.html:7
23+
msgid "previous"
24+
msgstr "anterior"
25+
26+
#: templates/pagination/pagination.html:21
27+
#: templates/pagination/pagination.html:23
28+
msgid "next"
29+
msgstr "próximo"

0 commit comments

Comments
 (0)