On Fri, May 2, 2008 at 11:11 AM, web-junkie <[EMAIL PROTECTED]> wrote:

>
> On 1 Mai, 19:32, "Justin Lilly" <[EMAIL PROTECTED]> wrote:
> > While it may be the long way around, can you not do the following?
> > a = Articles.objects.all()[:3]
> > a.reverse()
> >
> > That would probably be my solution.
>
> That's exactly what I tried, and as I described, it gives you
> something wrong, not the queryset reversed...
>

Now, I don't think what it give you is wrong, it's just not what you
wanted/expected.  Instead of reversing the result after retrieval/slicing
using the normal ordering, it is reversing the normal ordering and then
retrieving/slicing the result.  So, given a sequence with normal ordering:

a,b,c,....x,y.z

You are looking to get (c,b,a) instead of (z,y,x).  Below, you mention a doc
note that explains why it doesn't do what you want by noting that there is
no efficient way in SQL to produce the result you are looking for and say
that is nonsense.  If it is nonsense, could you please state the SQL
statement you would use to achieve the result you are looking for?

Karen


> >
> >
> > On Thu, May 1, 2008 at 12:36 PM, web-junkie <[EMAIL PROTECTED]> wrote:
> >
> > > Hi,
> >
> > > what is the new reverse() method good for? Seems it just swaps the
> > > order_by statement?
> > > I would appreciate a reverse() method that, if used after slicing,
> > > would actually reverse the queryset.
> > > In the docs it's said: "Django doesn't support that mode of access
> > > (slicing from the end), because it's not possible to do it efficiently
> > > in SQL."
> > > That is nonsense, because reverse should not slice from anywhere, it
> > > should just reverse, 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?
> >
> > --
> > Justin Lilly
> > Web Developer/Designerhttp://justinlilly.com- Zitierten Text ausblenden
> -
> >
> > - Zitierten Text anzeigen -
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to