mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Resolve assertion error with LimitOffsetPagination and erronous parameters. Closes #2920.
This commit is contained in:
parent
762a30dbda
commit
22631c73a7
|
@ -419,6 +419,8 @@ class LimitOffsetPagination(BasePagination):
|
|||
_divide_with_ceil(self.count - self.offset, self.limit) +
|
||||
_divide_with_ceil(self.offset, self.limit)
|
||||
)
|
||||
if current > final:
|
||||
current = final
|
||||
|
||||
def page_number_to_url(page_number):
|
||||
if page_number == 1:
|
||||
|
|
|
@ -435,6 +435,12 @@ class TestLimitOffset:
|
|||
]
|
||||
}
|
||||
|
||||
def test_erronous_offset(self):
|
||||
request = Request(factory.get('/', {'limit': 5, 'offset': 1000}))
|
||||
queryset = self.paginate_queryset(request)
|
||||
self.get_paginated_content(queryset)
|
||||
self.get_html_context()
|
||||
|
||||
def test_invalid_offset(self):
|
||||
"""
|
||||
An invalid offset query param should be treated as 0.
|
||||
|
|
Loading…
Reference in New Issue
Block a user