Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bug/MVBE-114/Incorrect-pagenumbers'
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanoch committed Jul 2, 2015
2 parents 15082b3 + 21d0114 commit df0ec68
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/django_ajax/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,19 @@ def paginate(request,

# Page number?
page_num = request.GET.get(page_variable, None)
number_of_pages = paginator.num_pages

if page_num:
try:
page_num = int(page_num)
page_num = max(page_num, 1) # Make sure page number isn't negative.
page_num = min(page_num, number_of_pages) # Make sure the pagenumber isn't bigger than the number of pages.
except ValueError:
page_num = 1
else:
# Default start page
if default_to_last_page:
page_num = paginator.num_pages
page_num = number_of_pages
else:
page_num = 1

Expand Down

0 comments on commit df0ec68

Please sign in to comment.