diff --git a/doc/api/fundamentals.rst b/doc/api/fundamentals.rst index b96bc6eccf..f57e9e2bbb 100644 --- a/doc/api/fundamentals.rst +++ b/doc/api/fundamentals.rst @@ -87,7 +87,8 @@ respectively, or ``null`` if there is no such page. You can use those URLs to re respective page. 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 -------------------- diff --git a/src/pretix/api/pagination.py b/src/pretix/api/pagination.py new file mode 100644 index 0000000000..a417a3c87d --- /dev/null +++ b/src/pretix/api/pagination.py @@ -0,0 +1,6 @@ +from rest_framework.pagination import PageNumberPagination + + +class Pagination(PageNumberPagination): + page_size_query_param = 'page_size' + max_page_size = 50 diff --git a/src/pretix/settings.py b/src/pretix/settings.py index 8784ab68de..e9db10e07e 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -393,7 +393,7 @@ REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ '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', 'PAGE_SIZE': 50, 'DEFAULT_AUTHENTICATION_CLASSES': (