-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
Proposal
We should change the default configuration of DEFAULT_PAGINATION_CLASS from its current default of rest_framework.pagination.PageNumberPagination. This would have parity with the PAGE_SIZE setting which is also currently set to None and has the effect of disabling the PageNumberPagination class which by default cannot be override with a query parameter because the default class has page_size_query_param = None which means the only way to enable pagination in the default behavior is to sub-class the PageNumberPagination to be able to pass a query parameter for page size, or to set the global PAGE_SIZE setting.
In addition to changing the default pagination class to be None, we would have a DeprecationWarning that alerts if PAGE_SIZE is set but the DEFAULT_PAGINATION_CLASS were None, meaning that any user that was before depending on the implicit default paginator and had set PAGE_SIZE would have to also now set the DEFAULT_PAGINATION_CLASS as well when upgrading.
Steps to reproduce
My Test Harness was based out of this: https://github.com/brjadams/drf_sprint/blob/master/testpage/urls.py
I used the default pagination settings and tested querying for results with and without the page_size query parameter, I found that the default was no pagination despite it having a pagination class. I also discovered the PAGE_SIZE was the magic variable to enable pagination for the default class but LimitOffsetPagination behaved more naturally as it allows the query parameters without having PAGE_SIZE be set, othewise by default LimitOffsetPagination does not paginate when a limit is not specified.
Expected behavior
Expected behavior is that global pagination settings are either fully enabled or fully disabled. We expect to not wind up in a spot where pagination doesn't work but appears in the schema, or that it does work and does not appear in the schema.
Actual behavior
By default today it is partially disabled such that there is a pagination class but no page size and it does appear in the schema regardless when the pagination class is specified.
Ref tickets: