From 6ddbd5543f4081e7f87055de8d35f57c9e939ab6 Mon Sep 17 00:00:00 2001 From: Rich Wareham Date: Fri, 12 Oct 2018 14:32:05 +0100 Subject: [PATCH 1/2] api: allow page size of lists to be configured Allow the page size of list responses to be specified. This is to allow the case where one doesn't really care about the resources but one wants the count. In this case, one can just set page_size to 1. DRF diasallows setting page_size to 0. --- api/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/views.py b/api/views.py index 72285af6..b6454be6 100644 --- a/api/views.py +++ b/api/views.py @@ -36,6 +36,7 @@ class ListPagination(pagination.CursorPagination): page_size = 50 + page_size_query_param = 'page_size' class FullTextSearchFilter(filters.SearchFilter): From 353b9e32e79ef037c2c4d1d25fe13c4c1b85067e Mon Sep 17 00:00:00 2001 From: Rich Wareham Date: Mon, 15 Oct 2018 13:39:33 +0100 Subject: [PATCH 2/2] api: set a maximum page size of 300 Some maximum needs to be set for the page sizes which can be returned. Set 300 as an arbitrary maximum. --- api/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/views.py b/api/views.py index b6454be6..23da1a5d 100644 --- a/api/views.py +++ b/api/views.py @@ -37,6 +37,7 @@ class ListPagination(pagination.CursorPagination): page_size = 50 page_size_query_param = 'page_size' + max_page_size = 300 class FullTextSearchFilter(filters.SearchFilter):