Skip to content

Commit 4fb6f6f

Browse files
committed
readme DESC/ASC order
1 parent 4b79425 commit 4fb6f6f

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

README.md

+36-18
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,42 @@ Paginating by pk, id or some `unique=True` field:
108108
page = paginator.paginate(queryset, lookup_field='pk', value=pk, per_page=20)
109109
```
110110

111+
## DESC/ASC order
112+
113+
DESC order:
114+
115+
```python
116+
page = paginator.paginate(
117+
# ...,
118+
lookup_field='-created_at')
119+
```
120+
121+
ASC order:
122+
123+
```python
124+
page = paginator.paginate(
125+
# ...,
126+
lookup_field='created_at')
127+
```
128+
129+
## Fetch next or prev page
130+
131+
Prev page:
132+
133+
```python
134+
page = paginator.paginate(
135+
# ...,
136+
move_to=paginator.PREV_PAGE)
137+
```
138+
139+
Next page:
140+
141+
```python
142+
page = paginator.paginate(
143+
# ...,
144+
move_to=paginator.NEXT_PAGE)
145+
```
146+
111147
## Serializers
112148

113149
Since paginating by a datetime and a pk is so common,
@@ -159,24 +195,6 @@ many records, otherwise they get expensive fast:
159195
* ``next_pages_left``
160196
* ``prev_pages_left``
161197

162-
## Fetch next or prev page
163-
164-
Prev page:
165-
166-
```python
167-
page = paginator.paginate(
168-
# ...,
169-
move_to=paginator.PREV_PAGE)
170-
```
171-
172-
Next page:
173-
174-
```python
175-
page = paginator.paginate(
176-
# ...,
177-
move_to=paginator.NEXT_PAGE)
178-
```
179-
180198
## Contributing
181199

182200
Feel free to check out the source code and submit pull requests.

0 commit comments

Comments
 (0)