#28036: Unexpected exception raised by previous_page_number() method - Django
Paginator
-------------------------------------+-------------------------------------
Reporter: Pat | Owner: nobody
Type: | Status: new
Uncategorized |
Component: | Version: 1.10
Uncategorized | Keywords: paginator,
Severity: Normal | InvalidPage
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
>>> objects = ['john', 'paul', 'george', 'ringo']
>>> p = Paginator(objects, 2)
>>> p.count
4
>>> p.num_pages
2
>>> page1 = p.page(1)
>>>
>>> page1.previous_page_number()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\Rick\ws2\env\lib\site-packages\django\core\paginator.py",
line 136
, in previous_page_number
return self.paginator.validate_number(self.number - 1)
File "C:\Users\Rick\ws2\env\lib\site-packages\django\core\paginator.py",
line 38,
in validate_number
raise EmptyPage('That page number is less than 1')
django.core.paginator.EmptyPage: That page number is less than 1
>>>
}}}
According to the `previous_page_number()` documentation.
Returns the previous page number. Raises `InvalidPage` if previous page
doesn’t exist.
I was expecting `previous_page_number()` to raise `InvalidPage` exception
as documentation says.
--
Ticket URL: <https://code.djangoproject.com/ticket/28036>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.e0cccd3078f974c33c3e65ef237979a7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.