Skip to content

Commit ab4e1bd

Browse files
yanivpmblayman
authored andcommitted
Fix for pagination ‘last’ link to give the real last page (#353)
* Fix for pagination ‘last’ link to give the real last page * Updated test to support new pagination ‘last’ link change * Added myself to AUTHORS
1 parent a12d98d commit ab4e1bd

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

‎AUTHORS

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Greg Aker <greg@gregaker.net>
44
Jerel Unruh <mail@unruhdesigns.com>
55
Matt Layman <http://www.mattlayman.com>
66
Oliver Sauder <os@esite.ch>
7-
7+
Yaniv Peer <yanivpeer@gmail.com>

‎example/tests/unit/test_pagination.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_valid_offset_limit(self):
4141
offset = 10
4242
limit = 5
4343
count = len(self.queryset)
44-
last_offset = count - limit
44+
last_offset = (count // limit) * limit
4545
next_offset = 15
4646
prev_offset = 5
4747

‎rest_framework_json_api/pagination.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_last_link(self):
6464
url = self.request.build_absolute_uri()
6565
url = replace_query_param(url, self.limit_query_param, self.limit)
6666

67-
offset = self.count - self.limit
67+
offset = (self.count // self.limit) * self.limit
6868

6969
if offset <= 0:
7070
return remove_query_param(url, self.offset_query_param)

0 commit comments

Comments
 (0)