mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-09-16 17:22:32 +03:00
Allow REST_FRAMEWORK.PAGE_SIZE to be overriden in settings
This commit is contained in:
parent
d252d22343
commit
4f18318b1c
|
@ -166,9 +166,6 @@ class PageNumberPagination(BasePagination):
|
|||
http://api.example.org/accounts/?page=4
|
||||
http://api.example.org/accounts/?page=4&page_size=100
|
||||
"""
|
||||
# The default page size.
|
||||
# Defaults to `None`, meaning pagination is disabled.
|
||||
page_size = api_settings.PAGE_SIZE
|
||||
|
||||
django_paginator_class = DjangoPaginator
|
||||
|
||||
|
@ -191,6 +188,13 @@ class PageNumberPagination(BasePagination):
|
|||
|
||||
invalid_page_message = _('Invalid page.')
|
||||
|
||||
@property
|
||||
def page_size(self):
|
||||
# The default page size.
|
||||
# Defaults to `None`, meaning pagination is disabled.
|
||||
# Property so that PAGE_SIZE can be overriden by @override_settings
|
||||
return api_settings.PAGE_SIZE
|
||||
|
||||
def paginate_queryset(self, queryset, request, view=None):
|
||||
"""
|
||||
Paginate a queryset if required, either returning a
|
||||
|
|
Loading…
Reference in New Issue
Block a user