File tree 1 file changed +36
-18
lines changed
1 file changed +36
-18
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,42 @@ Paginating by pk, id or some `unique=True` field:
108
108
page = paginator.paginate(queryset, lookup_field = ' pk' , value = pk, per_page = 20 )
109
109
```
110
110
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
+
111
147
## Serializers
112
148
113
149
Since paginating by a datetime and a pk is so common,
@@ -159,24 +195,6 @@ many records, otherwise they get expensive fast:
159
195
* `` next_pages_left``
160
196
* `` prev_pages_left``
161
197
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
-
180
198
# # Contributing
181
199
182
200
Feel free to check out the source code and submit pull requests.
You can’t perform that action at this time.
0 commit comments