Skip to content

Commit

Permalink
LimitOffsetPagination zero final page fix, closes encode#3303
Browse files Browse the repository at this point in the history
  • Loading branch information
ugurunver committed Aug 19, 2015
1 parent ed65db3 commit 8c280d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rest_framework/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ def get_html_context(self):
_divide_with_ceil(self.count - self.offset, self.limit) +
_divide_with_ceil(self.offset, self.limit)
)

# Final page must be at least first page
if not final:
final = 1

if current > final:
current = final

Expand Down

1 comment on commit 8c280d0

@tomchristie
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Adopted a fix based on this, but with a very slightly different style (feels marginally more robust).
Good work raising the issue & proposed fix.

Please sign in to comment.