Opened 13 years ago
Last modified 12 years ago
#17159 closed New feature
Paginator.Page() should throw an exception for invalid [next|previous]_page_number() — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Other) | Version: | 1.3 |
Severity: | Normal | Keywords: | paginator core |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
The next_page_number() and previous_page_number() currently return an incremented or decremented number without verifying if the page is in the range or not. They should instead throw an exception.
Repro Steps
=======
from django.core.paginator import Paginator
objects = ['john', 'paul', 'george', 'ringo', 'bill', 'gates', 'steve', 'jobs']
p = Paginator(objects, 2)
p.count
8
p.num_pages
4
p.page_range
[1, 2, 3, 4]
p.page(1).has_previous()
False
p.page(4).has_next()
False
p.page(1).previous_page_number() ### Should throw Exception
0
p.page(4).next_page_number() ### Should throw Exception
5