API: Allow to set a custom pagination size

This commit is contained in:
Raphael Michel
2021-07-13 18:19:41 +02:00
parent ac16d9d900
commit 75dc80eb09
3 changed files with 9 additions and 2 deletions

View File

@@ -87,7 +87,8 @@ respectively, or ``null`` if there is no such page. You can use those URLs to re
respective page. respective page.
The field ``results`` contains a list of objects representing the first results. For most The field ``results`` contains a list of objects representing the first results. For most
objects, every page contains 50 results. objects, every page contains 50 results. You can specify a lower pagination size using the
``page_size`` query parameter, but no more than 50.
Conditional fetching Conditional fetching
-------------------- --------------------

View File

@@ -0,0 +1,6 @@
from rest_framework.pagination import PageNumberPagination
class Pagination(PageNumberPagination):
page_size_query_param = 'page_size'
max_page_size = 50

View File

@@ -393,7 +393,7 @@ REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
'pretix.api.auth.permission.EventPermission', 'pretix.api.auth.permission.EventPermission',
], ],
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'DEFAULT_PAGINATION_CLASS': 'pretix.api.pagination.Pagination',
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.NamespaceVersioning', 'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.NamespaceVersioning',
'PAGE_SIZE': 50, 'PAGE_SIZE': 50,
'DEFAULT_AUTHENTICATION_CLASSES': ( 'DEFAULT_AUTHENTICATION_CLASSES': (