Re: [SQLObject] Sorting a list of selected SQLObjects
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Mark <mar...@gm...> - 2010-07-04 21:25:01
|
> > subs_sel = list(BBSubs.select(BBSubs.q.user_id==1)) > > for sub in subs_sel: > > sub.topic = BBTopic.get(sub.topic_id) > > sub.post = BBPost.get(sub.topic.last_post_id) > > sub.forum = BBForum.get(sub.topic.forum_id) > > Why do you assign values explicitly Why not to use ForeignKey? > > > subs = sorted(subs_sel, lambda x: x.topic.last_post_id) > > I don't see any problem with the code. Can you write a short standalone > script that I can run to see the problem? > > Oleg. Thanks for the tip on ForeignKey, I've been doing a lot of the above without using it and I knew I was missing something. The problem was a missing key= in the sorted function as I typed from memory and forgot it. subs = sorted(subs_sel, key=lambda x: x.topic.last_post_id) |