#29680: Paginate start with last Page
-------------------------------------+-------------------------------------
               Reporter:  Dario      |          Owner:  Dario Navin
  Navin                              |
                   Type:             |         Status:  assigned
  Cleanup/optimization               |
              Component:  Generic    |        Version:  2.1
  views                              |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Hi,

 currently you can't set the paginate to start with the last page if no
 page is given unless you put in the url.

 MultipleObjectMixin:
 {{{
         page_kwarg = self.page_kwarg
         # I suggest removing the static 1 and replace it with a function
 called
         # get_start_page whose default return value is 1
         page = self.kwargs.get(page_kwarg) or
 self.request.GET.get(page_kwarg) or 1
         try:
             page_number = int(page)
         except ValueError:
             if page == 'last':
                 page_number = paginator.num_pages
             else:
                 raise Http404(_("Page is not 'last', nor can it be
 converted to an int."))
 }}}

 Suggested change:

 {{{
 page = self.kwargs.get(page_kwarg) or self.request.GET.get(page_kwarg) or
 self.get_start_page()
 }}}

 Default would be 1. Then for starting with the last page someone could set
 it to

 {{{
 def get_start_page(self):
        return self.get_paginator().num_pages
 }}}


 I did search but could not find any report about it.

 If someone could approve this, I would submit a fix.

 Best regards,

 Dario Heinisch

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

Reply via email to