#17159: Paginator.Page() should throw an exception for invalid
[next|previous]_page_number()
--------------------------------+----------------------------
     Reporter:  mehta.apurva@…  |      Owner:  nobody
         Type:  Bug             |     Status:  new
    Component:  Core (Other)    |    Version:  1.3
     Severity:  Normal          |   Keywords:  paginator core
 Triage Stage:  Unreviewed      |  Has patch:  0
Easy pickings:  1               |      UI/UX:  0
--------------------------------+----------------------------
 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
 >>>

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17159>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to