This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Description
It would be very useful to have an option to default to the first page if hitting a wrong page object.
I suggest to basically replace https://github.com/pydanny/dj-pagination/blob/master/dj_pagination/templatetags/pagination_tags.py#L186-L196 with something like this:
try:
page_obj = paginator.page(request.page(page_suffix))
except InvalidPage:
if INVALID_PAGE_RAISES_404:
raise Http404(
"Invalid page requested. If DEBUG were set to "
+ "False, an HTTP 404 page would have been shown instead."
)
if SHOW_FIRST_PAGE_WHEN_INVALID
# fallback to first page
page_obj = paginator.page(1)
else:
context[key] = []
context["invalid_page"] = True
return ""