Re: Ordering of querysets

2011-03-07 Thread Tom Evans
On Fri, Mar 4, 2011 at 8:40 PM, Sidney Cadot wrote: > Hi Tom, > >> Unless I'm being dense, you cannot represent this as a single SQL >> query, so logically you cannot represent this as a QuerySet. > > It is possible by using a nested query, e.g. > > SELECT * FROM (SELECT * FROM some_table ORDER BY

Re: Ordering of querysets

2011-03-04 Thread Michael Radziej
On Fri, 4 Mar 2011 21:40:36 +0100, Sidney Cadot wrote: Hi Sidney, > It is possible by using a nested query, e.g. > > SELECT * FROM (SELECT * FROM some_table ORDER BY timestamp DESC LIMIT 10) > ORDER BY timestamp ASC; Nice, but it doesn't make sense. It makes everything harder to understand. Reve

Re: Ordering of querysets

2011-03-04 Thread Sidney Cadot
Hi Tom, > Unless I'm being dense, you cannot represent this as a single SQL > query, so logically you cannot represent this as a QuerySet. It is possible by using a nested query, e.g. SELECT * FROM (SELECT * FROM some_table ORDER BY timestamp DESC LIMIT 10) ORDER BY timestamp ASC; But I suppose

Re: Ordering of querysets

2011-03-04 Thread Tom Evans
On Fri, Mar 4, 2011 at 4:06 PM, reddish wrote: > Hi, > > I have trouble getting a QuerySet to do what I want. I need to select > the last 10 items of a certain model (ordered by timestamp; so the > "most recent" 10 items), and when I iterate over them during template > processing I want the earlie

Ordering of querysets

2011-03-04 Thread reddish
Hi, I have trouble getting a QuerySet to do what I want. I need to select the last 10 items of a certain model (ordered by timestamp; so the "most recent" 10 items), and when I iterate over them during template processing I want the earliest item (with the oldest timestamp) to come first. I've tr