librelist archives

« back to archive

Help with ordering in Flask-SQLALchemy

Help with ordering in Flask-SQLALchemy

From:
Samrat Man Singh
Date:
2011-07-19 @ 12:36
Hi,
I'm trying to order a query in descending order (so that the most recent
entries appear first). I didn't find anything related on the
Flask-SQLAlchemy docs and a search on StackOverflow hinted towards the use
of 'desc' but when I tried importing it(as suggested

here<http://stackoverflow.com/questions/4186062/sqlalchemy-order-by-descending/4186078#4186078>),
it didn't work. How do I use desc?

Samrat

Re: Help with ordering in Flask-SQLALchemy

From:
Samrat Man Singh
Date:
2011-07-19 @ 13:23
Tried posts = Post.query.order_by(Post.pub_date.desc()) and it worked!! :D

On Tue, Jul 19, 2011 at 6:21 PM, Samrat Man Singh
<samratmansingh@gmail.com>wrote:

> Hi,
> I'm trying to order a query in descending order (so that the most recent
> entries appear first). I didn't find anything related on the
> Flask-SQLAlchemy docs and a search on StackOverflow hinted towards the use
> of 'desc' but when I tried importing it(as suggested 
here<http://stackoverflow.com/questions/4186062/sqlalchemy-order-by-descending/4186078#4186078>),
> it didn't work. How do I use desc?
>
> Samrat
>