From ec4761225e5a1683b046752e7090e91abfa52f54 Mon Sep 17 00:00:00 2001 From: dfavato Date: Tue, 23 Aug 2016 14:52:20 -0300 Subject: [PATCH] Set self.count before self.limit in LimitOffsetPagination By doing this it is possible to override get_limit in order to return all records if the request has a predefined param. For example, if one wants that all records are retrieved if url has &limit=-1, get_limit could return self.count in this case. Otherwise, if self.count is set after self.limit then, to achive the same result, one has to override get_limit and paginate_queryset, or run get_limit twice. --- rest_framework/pagination.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index c54894efc5..755debea3d 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -303,12 +303,12 @@ class LimitOffsetPagination(BasePagination): template = 'rest_framework/pagination/numbers.html' def paginate_queryset(self, queryset, request, view=None): + self.count = _get_count(queryset) self.limit = self.get_limit(request) if self.limit is None: return None self.offset = self.get_offset(request) - self.count = _get_count(queryset) self.request = request if self.count > self.limit and self.template is not None: self.display_page_controls = True pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy