1
- # infinite-scroll-pagination [ ![ Build Status] ( https://travis-ci.org/nitely/django-infinite-scroll-pagination.png )] ( https://travis-ci.org/nitely/django-infinite-scroll-pagination ) [ ![ Coverage Status] ( https://coveralls.io/repos/nitely/django-infinite-scroll-pagination/badge.png?branch=master )] ( https://coveralls.io/r/nitely/django-infinite-scroll-pagination?branch=master )
1
+ # infinite-scroll-pagination
2
+
3
+ [ ![ Build Status] (https://img.shields.io/travis/nitely/django-infinite-scroll-pagination
4
+ /master.svg?style=flat-square)] (https://travis-ci.org/nitely/django-infinite-scroll-pagination
5
+ )
6
+ [ ![ Coverage Status] (https://img.shields.io/coveralls/nitely/django-infinite-scroll-pagination
7
+ /master.svg?style=flat-square)] (https://coveralls.io/r/nitely/django-infinite-scroll-pagination
8
+ )
9
+ [ ![ pypi] (https://img.shields.io/pypi/v/django-infinite-scroll-pagination
10
+ .svg?style=flat-square)] (https://pypi.python.org/pypi/django-infinite-scroll-pagination
11
+ )
12
+ [ ![ licence] (https://img.shields.io/pypi/l/django-infinite-scroll-pagination
13
+ .svg?style=flat-square)] (https://raw.githubusercontent.com/nitely/django-infinite-scroll-pagination
14
+ /master/LICENSE)
2
15
3
16
infinite-scroll-pagination is a Django lib that implements
4
17
[ the seek method] ( http://use-the-index-luke.com/sql/partial-results/fetch-next-page )
5
- (AKA Keyset Paging and Cursor Pagination) for scalable pagination.
18
+ (AKA Keyset Paging or Cursor Pagination) for scalable pagination.
6
19
7
20
> Note despite its name, this library can be used as a regular paginator,
8
- a better name would have been `` seek-paginator `` , `` keyset-paginator `` or
9
- `` cursor-paginator `` but it's too late for that now, haha : D
21
+ a better name would have been `` seek-paginator `` , `` keyset-paginator `` ,
22
+ `` cursor-paginator `` or `` offset-less-paginator `` but it's too late for that now, haha : D
10
23
11
24
## How it works
12
25
@@ -23,7 +36,7 @@ Nor do rows mysteriously vanish between pages. These anomalies are common
23
36
with the * offset/limit* based approach, but the * keyset* based solution does
24
37
a much better job at avoiding them.
25
38
* is fast: all operations can be solved with a fast row positioning followed
26
- by a range scan in the desired direction
39
+ by a range scan in the desired direction.
27
40
28
41
For a full explanation go to
29
42
[ the seek method] ( http://use-the-index-luke.com/sql/partial-results/fetch-next-page )
@@ -35,14 +48,20 @@ infinite-scroll-pagination requires the following software to be installed:
35
48
* Python 2.7, 3.4, 3.5 or 3.6
36
49
* Django 1.11 LTS, 2.0 or 2.1
37
50
51
+ ## Install
52
+
53
+ ```
54
+ pip install django-infinite-scroll-pagination
55
+ ```
56
+
38
57
## Django Rest Framework (DRF)
39
58
40
59
DRF has the built-in ` CursorPagination `
41
60
that is similar to this lib. Use that instead.
42
61
43
62
## Usage
44
63
45
- This example pages by a ` created_at ` date field:
64
+ This example paginates by a ` created_at ` date field:
46
65
47
66
``` python
48
67
# views.py
@@ -91,7 +110,7 @@ def pagination_ajax(request):
91
110
return HttpResponse(json.dumps(data), content_type = " application/json" )
92
111
```
93
112
94
- Paging by pk, id or some ` unique=True ` field:
113
+ Paginating by pk, id or some ` unique=True ` field:
95
114
96
115
``` python
97
116
page = paginator.paginate(queryset, lookup_field = ' pk' , value = pk, per_page = 20 )
@@ -104,7 +123,7 @@ there is a serializers that will convert both values to ``timestamp-pk``,
104
123
for example: `` 1552349160.099628-5 `` , this can be later be used
105
124
as a query string `` https://.../articles/?p=1552349160.099628-5 `` .
106
125
There is no need to do the conversion client side, the server can send
107
- the next/previous page keyset serialized, as shown in the "Usage" section
126
+ the next/previous page keyset serialized, as shown in the "Usage" section.
108
127
109
128
Serialize:
110
129
@@ -135,7 +154,7 @@ class Article(models.Model):
135
154
models.Index(fields = [' -created_at' , ' -pk' ])]
136
155
```
137
156
138
- > Note: an index is require for each direction ,
157
+ > Note: an index is require for both directions ,
139
158
since the query has a `LIMIT ` .
140
159
See [indexes- ordering](https:// www.postgresql.org/ docs/ 9.3 / indexes- ordering.html)
141
160
@@ -170,7 +189,7 @@ page = paginator.paginate(
170
189
171
190
Feel free to check out the source code and submit pull requests.
172
191
173
- You may also report any bug or propose new features in the
192
+ Please, report any bug or propose new features in the
174
193
[issues tracker](https:// github.com/ nitely/ django- infinite- scroll- pagination/ issues)
175
194
176
195
# # Copyright / License
0 commit comments