Specifying descending order_by on a backref

1,697 views
Skip to first unread message

Ken

unread,
Feb 17, 2009, 5:03:53 PM2/17/09
to sqlalchemy
I'm using the declarative extension. When I specify a backref on a
relation, I see the order_by argument and I'm pointing it to the
column object. That works, but I need to sort the backref
descendingly, not ascendingly. I don't see an option for that in the
Relation()/backref() arguments. What am I missing?

Thanks ahead of time.

-Ken

Michael Trier

unread,
Feb 17, 2009, 5:13:26 PM2/17/09
to sqlal...@googlegroups.com
backref supports the same arguments as relation(), which include an order_by argument.

http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html?highlight=backref#sqlalchemy.orm.relation
--
Michael Trier
http://blog.michaeltrier.com/
http://thisweekindjango.com/

Ken

unread,
Feb 17, 2009, 5:22:31 PM2/17/09
to sqlalchemy
On Feb 17, 3:13 pm, Michael Trier <mtr...@gmail.com> wrote:
> backref supports the same arguments as relation(), which include an order_by
> argument.
>
> http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html?highligh...

Michael, I'm using the order_by argument. The problem is that it's
sorting my values ascendingly instead of descendingly.

Michael Trier

unread,
Feb 17, 2009, 5:29:14 PM2/17/09
to sqlal...@googlegroups.com
Hi,
Sorry, I misunderstood. You should be able to do a order_by=field.desc().

Ken

unread,
Feb 17, 2009, 5:50:56 PM2/17/09
to sqlalchemy
On Feb 17, 3:29 pm, Michael Trier <mtr...@gmail.com> wrote:
>
> Sorry, I misunderstood. You should be able to do a order_by=field.desc().

Ah, that answers my question. Thanks!
Reply all
Reply to author
Forward
0 new messages