If a user asks for a page beyond the range of pages, an EmptyPage
exception is thrown. Catch this and clamp the page number
appropriately.
Reported-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Tested-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Stephen Finucane <stephen@that.guru>
except ValueError:
page_no = 1
self.current_page = self.page(page_no)
+ except paginator.EmptyPage:
+ if page_no < 1:
+ page_no = 1
+ else:
+ page_no = self.num_pages
+ self.current_page = self.page(page_no)
self.leading_set = self.trailing_set = []