#28032: Abstract away pagination boilerplate
-------------------------------------+-------------------------------------
               Reporter:  Ian Foote  |          Owner:  nobody
                   Type:             |         Status:  new
  Cleanup/optimization               |
              Component:  Core       |        Version:  master
  (Other)                            |       Keywords:  Pagination
               Severity:  Normal     |  Paginator
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 In the [https://docs.djangoproject.com/en/1.11/topics/pagination/#using-
 paginator-in-a-view documentation for pagination], we recommend using this
 boilerplate:


 {{{
  try:
         contacts = paginator.page(page)
     except PageNotAnInteger:
         # If page is not an integer, deliver first page.
         contacts = paginator.page(1)
     except EmptyPage:
         # If page is out of range (e.g. 9999), deliver last page of
 results.
         contacts = paginator.page(paginator.num_pages)
 }}}

 This could be abstracted away into a simple method on the
 
[https://github.com/django/django/blob/5a6f70b4281817656db2f36c5919036d38fcce7f/django/core/paginator.py#L25
 {{{Paginator}}}] class, perhaps named something like
 {{{results_for_page}}}.

--
Ticket URL: <https://code.djangoproject.com/ticket/28032>
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/052.ee366dba9f3aaec0c43157c4894e722b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to