That is what I do at the moment, putting it in a list in such an order that it is reversed.
On 2 Mai, 19:58, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote: > On Thu, 2008-05-01 at 09:36 -0700, web-junkie wrote: > > Hi, > > > what is the newreverse() method good for? Seems it just swaps the > > order_by statement? > > I would appreciate areverse() method that, if used after slicing, > > would actuallyreversethe queryset. > > In the docs it's said: "Django doesn’t support that mode of access > > (slicing from the end), because it’snotpossible to do it efficiently > > in SQL." > > That is nonsense, becausereverseshouldnotslice from anywhere, it > > should justreverse, and you can do that in python. > > So when I have Articles.objects.all()[:3] which gives me a,b,c, > > Articles.objects.all()[:3].reverse() would make c,b,a out of it,not > > z,y,x! Or am I missing something? > > The problem seems to be in getting the ORM to write an appropriate query > to return the results you want. Would it work for your needs if you > pull it out of the queryset into a list, and thenreverseit at the > python level? > > Something like this (untested code follows) > > py>>> arts = Articles.objects.all()[:3] > py>>> arts = list(arts) > py>>> arts.reverse() > > The drawback, of course, is that you no longer have a query set, so > whether this will work for you depends on your use case. > > Cheers, > Cliff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---