From aa4cd7e9d7050b294c0b5169b5eaab0b6819bb26 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 20 Aug 2015 10:12:52 +0100 Subject: [PATCH] Guard against LimitOffsetPagination edge case. Closes #3303. --- rest_framework/pagination.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index f88503541..bf72ef4fc 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -423,6 +423,9 @@ class LimitOffsetPagination(BasePagination): _divide_with_ceil(self.count - self.offset, self.limit) + _divide_with_ceil(self.offset, self.limit) ) + if final < 1: + final = 1 + if current > final: current = final