Skip to content

Commit 19b415e

Browse files
Improve pagination docs. Refs #4304 [ci skip]
1 parent f0f61aa commit 19b415e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/api-guide/pagination.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ Pagination can be turned off by setting the pagination class to `None`.
2121

2222
## Setting the pagination style
2323

24-
The default pagination style may be set globally, using the `DEFAULT_PAGINATION_CLASS` settings key. For example, to use the built-in limit/offset pagination, you would do:
24+
The default pagination style may be set globally, using the `DEFAULT_PAGINATION_CLASS` and `PAGE_SIZE` setting keys. For example, to use the built-in limit/offset pagination, you would do something like this:
2525

2626
REST_FRAMEWORK = {
27-
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination'
27+
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
28+
'PAGE_SIZE': 100
2829
}
2930

31+
Note that you need to set both the pagination class, and the page size that should be used.
32+
3033
You can also set the pagination class on an individual view by using the `pagination_class` attribute. Typically you'll want to use the same pagination style throughout your API, although you might want to vary individual aspects of the pagination, such as default or maximum page size, on a per-view basis.
3134

3235
## Modifying the pagination style
@@ -109,7 +112,7 @@ To set these attributes you should override the `PageNumberPagination` class, an
109112

110113
## LimitOffsetPagination
111114

112-
This pagination style mirrors the syntax used when looking up multiple database records. The client includes both a "limit" and an
115+
This pagination style mirrors the syntax used when looking up multiple database records. The client includes both a "limit" and an
113116
"offset" query parameter. The limit indicates the maximum number of items to return, and is equivalent to the `page_size` in other styles. The offset indicates the starting position of the query in relation to the complete set of unpaginated items.
114117

115118
**Request**:

0 commit comments

Comments
 (0)