From 7d1fc1f501ba94e35207ebb5bc9f1aae8d355c14 Mon Sep 17 00:00:00 2001 From: Dmitry Mugtasimov Date: Fri, 27 Jul 2018 14:10:25 +0300 Subject: [PATCH 1/2] Do not do `SELECT count(*) FROM ...` if pagination is not requested --- rest_framework/pagination.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index 1c57f17d31..b3e3b46aa8 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -322,11 +322,12 @@ class LimitOffsetPagination(BasePagination): template = 'rest_framework/pagination/numbers.html' def paginate_queryset(self, queryset, request, view=None): - self.count = self.get_count(queryset) self.limit = self.get_limit(request) if self.limit is None: return None + self.count = self.get_count(queryset) + self.offset = self.get_offset(request) self.request = request if self.count > self.limit and self.template is not None: From dcfa02e7afebd3cc70ca3c80ca6d3cfcd5581483 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 9 Mar 2021 12:05:28 +0000 Subject: [PATCH 2/2] Update pagination.py --- rest_framework/pagination.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index b3e3b46aa8..942992cf6d 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -327,7 +327,6 @@ def paginate_queryset(self, queryset, request, view=None): return None self.count = self.get_count(queryset) - self.offset = self.get_offset(request) self.request = request if self.count > self.limit and self.template is not None: