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

Comment (by Dario Navin):

 Replying to [comment:1 Tim Graham]:
 > What's the use case for starting pagination on the last page? Couldn't
 you just reverse the order of whatever you're paginating?

 Forums use the same schema as well as displaying messages.

 Let's say I have a simple Message model.



 I want to display my messages with the latest message being on the bottom:

 1. First Message
 2. Second Message
 3. ....
 4. Latest Message

 In the current state I would have to order the queryset decending by id in
 my view to get the last message on the first page.



 {{{
 class SingleMessageDetailView(ListView):
     model = Message
     template_name = 'message.html'
     paginate_by = 10
     context_object_name = "messages"
     ordering = "-id"
 }}}

 But now I am facing the problem that the last message is the first object
 in my queryset.
 I could solve it by reversing the queryset in the template but in my
 opinion that is not a beautiful code since we have to make two adjustments
 at two different ends.


 {{{
 {% for obj in messages reversed %}
 }}}


 Having the option to start at the last page would make it easier &
 friendlier for development.

 The other current option is to use a function based view or to change the
 url:


 {{{
 # Normally I would move the 'page last part' to the absolute url but for
 demonstration purpose I have put it in the html code.
 <a href="{{ message.get_absolute_url }}?page=last">{{ message.subject
 }}</a>
 }}}


 Also, jumping to the last page is quite common in forums and follows the
 "book-style".

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

Reply via email to