On Tue, Jul 30, 2013 at 11:04 PM, Wim Lewis <[email protected]> wrote: > > On 30 Jul 2013, at 2:06 PM, Florian Apolloner wrote: >> How do you think such support would look like? For negative indices you'd >> have to know the size of the resultset to be able to do "limit somthing >> offset length-your_negative_index" -- this doesn't seem to make any sense >> for an ORM. You can always do list(qs)]:-1] though… > > It seems like the first comment in the ticket answers that question. Django > would reverse the sense of the query's ordering clause and use a simple LIMIT. >
What would it do if the query had already been evaluated? IE, how many queries does this run? qs = Model.objects.filter(…).order_by(…) print qs[0] print qs[-1] print qs[0] If it is as simple as reversing the order by and negating the index, then the programmer themselves can do this, there is no need for magic. Having code that looks like it is a simple operation, but is in fact changing the logic of when queries are evaluated is evil in my opinion. -1 Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django developers" 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]. Visit this group at http://groups.google.com/group/django-developers. For more options, visit https://groups.google.com/groups/opt_out.
