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 Version 2
Reported by: | Owned by: | ||
---|---|---|---|
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 (last modified by )
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
Change History (2)
comment:1 by , 13 years ago
Owner: | changed from | to
---|
comment:2 by , 13 years ago
Description: | modified (diff) |
---|---|
Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.
That makes sense. It would be a matter of calling
Page.paginator.validate_number()
.