@@ -16,7 +16,7 @@ REST_FRAMEWORK = {
1616    ' PAGE_SIZE' 10 ,
1717    ' EXCEPTION_HANDLER' ' rest_framework_json_api.exceptions.exception_handler' 
1818    ' DEFAULT_PAGINATION_CLASS' 
19-         ' rest_framework_json_api.pagination.JSONAPIPageNumberPagination ' 
19+         ' rest_framework_json_api.pagination.JsonApiPageNumberPagination ' 
2020    ' DEFAULT_PARSER_CLASSES' 
2121        ' rest_framework_json_api.parsers.JSONParser' 
2222        ' rest_framework.parsers.FormParser' 
@@ -50,6 +50,8 @@ DJA pagination is based on [DRF pagination](https://www.django-rest-framework.or
5050When pagination is enabled, the renderer will return a ` meta `  object with
5151record count and a ` links `  object with the next, previous, first, and last links.
5252
53+ Optional query parameters can also be provided to customize the page size or offset limit.
54+ 
5355#### Configuring the Pagination Style  
5456
5557Pagination style can be set on a particular viewset with the ` pagination_class `  attribute or by default for all viewsets
@@ -59,35 +61,42 @@ You can configure fixed values for the page size or limit -- or allow the client
5961via query parameters.
6062
6163Two pagination classes are available:
62- -  ` JSONAPIPageNumberPagination `  breaks a response up into pages that start at a given page number
63-    with a given size  (number of items per page). It can be configured with the following attributes:
64+ -  ` JsonApiPageNumberPagination `  breaks a response up into pages that start at a given page number with a given size  
65+   (number of items per page). It can be configured with the following attributes:
6466  -  ` page_query_param `  (default ` page[number] ` )
6567  -  ` page_size_query_param `  (default ` page[size] ` ) Set this to ` None `  if you don't want to allow the client 
6668     to specify the size.
69+   -  ` page_size `  (default ` REST_FRAMEWORK['PAGE_SIZE'] ` ) default number of items per page unless overridden by
70+      ` page_size_query_param ` .
6771  -  ` max_page_size `  (default ` 100 ` ) enforces an upper bound on the ` page_size_query_param ` .
6872     Set it to ` None `  if you don't want to enforce an upper bound.
69- -  ` JSONAPILimitOffsetPagination `  breaks a response up into pages that start from an item's offset
70-   in the viewset for a given number of items (the limit).
73+ 
74+ -  ` JsonApiLimitOffsetPagination `  breaks a response up into pages that start from an item's offset in the viewset for 
75+   a given number of items (the limit).
7176  It can be configured with the following attributes:
7277  -  ` offset_query_param `  (default ` page[offset] ` ).
7378  -  ` limit_query_param `  (default ` page[limit] ` ).
79+   -  ` default_limit `  (default ` REST_FRAMEWORK['PAGE_SIZE'] ` ) is the default number of items per page unless
80+      overridden by ` limit_query_param ` .
7481  -  ` max_limit `  (default ` 100 ` ) enforces an upper bound on the limit.
7582     Set it to ` None `  if you don't want to enforce an upper bound.
7683
77- 
84+ #####  Examples 
7885These examples show how to configure the parameters to use non-standard names and different limits:
7986
8087``` python 
81- from  rest_framework_json_api.pagination import  JSONAPIPageNumberPagination, JSONAPILimitOffsetPagination 
88+ from  rest_framework_json_api.pagination import  JsonApiPageNumberPagination, JsonApiLimitOffsetPagination 
8289
83- class  MyPagePagination (JSONAPIPageNumberPagination ):
90+ class  MyPagePagination (JsonApiPageNumberPagination ):
8491    page_query_param =  ' page_number' 
85-     page_size_query_param =  ' page_size' 
92+     page_size_query_param =  ' page_length' 
93+     page_size =  3 
8694    max_page_size =  1000 
8795
88- class  MyLimitPagination (JSONAPILimitOffsetPagination ):
96+ class  MyLimitPagination (JsonApiLimitOffsetPagination ):
8997    offset_query_param =  ' offset' 
9098    limit_query_param =  ' limit' 
99+     default_limit =  3 
91100    max_limit =  None 
92101``` 
93102
@@ -146,7 +155,7 @@ If you are also using [`rest_framework.filters.SearchFilter`](https://django-res
146155(which performs single parameter searchs across multiple fields) you'll want to customize the name of the query
147156parameter for searching to make sure it doesn't conflict with a field name defined in the filterset.
148157The recommended value is: ` search_param="filter[search]" `  but just make sure it's
149- ` filter[_something_] `  to comply with the jsonapi  spec requirement to use the filter
158+ ` filter[_something_] `  to comply with the JSON : API  spec requirement to use the filter
150159keyword. The default is "search" unless overriden.
151160
152161The filter returns a ` 400 Bad Request `  error for invalid filter query parameters as in this example
@@ -446,7 +455,7 @@ class OrderSerializer(serializers.ModelSerializer):
446455
447456``` 
448457
449- In the [ JSON  API spec] ( http://jsonapi.org/format/#document-resource-objects ) ,
458+ In the [ JSON: API  spec] ( http://jsonapi.org/format/#document-resource-objects ) ,
450459relationship objects contain links to related objects. To make this work
451460on a serializer we need to tell the ` ResourceRelatedField `  about the
452461corresponding view. Use the ` HyperlinkedModelSerializer `  and instantiate
@@ -584,7 +593,7 @@ class OrderSerializer(serializers.HyperlinkedModelSerializer):
584593### RelationshipView  
585594` rest_framework_json_api.views.RelationshipView `  is used to build
586595relationship views (see the
587- [ JSON  API spec] ( http://jsonapi.org/format/#fetching-relationships ) ).
596+ [ JSON: API  spec] ( http://jsonapi.org/format/#fetching-relationships ) ).
588597The ` self `  link on a relationship object should point to the corresponding
589598relationship view.
590599
0 commit comments