Instead of row.id, try: row.post.id :-)
Marin On Fri, Dec 23, 2011 at 2:34 PM, Thomas Dall'Agnese < [email protected]> wrote: > Hi, > > Is it possible to get the ID of a row in a virtual field? > > I tried the following piece of code to virtually get the number of > comments of a given post (assuming two tables "post" and "comment" where a > "comment" entry can have a "post", so a post as many comments): > db.post.virtual_comments_nb= Field.Virtual(lambda row: db(db.comment.post > == row.id).count()) > > But the key "id" is not in the object "row". > The key "key" neither. > > How can I get the row ID in the lambda? >

