On 23 February 2012 00:30, naveed <nav...@gmail.com> wrote: > A slightly related question: In the grid, how can I show values from > referenced tables? > > I have the table: > db.define_table('table1', > Field('field1'), > Field('usr', db.auth_user)) > > How can I show the user's first and last names in the grid for table1? The > ignores the usr column altogether, when I put it in fields. >
One way is to use represent. In this example I use uuid's to refer to other tables in stead of the default way of using the id's: db.akb_articles.journal.represent = lambda x, record: db( db.akb_journal.uuid == x).select( db.akb_journal.title).first()['title'] In the grid the 'journal' field from akb_articles will show the 'title'-field of the akb_journal table. Another way is to do it in your query - combined with the 'fields = [ ]' parameter where in this case I would use something like query = db.akb_articles.journal == db.akb_journal.uuid and fields = [db.akb_articles.title, db.akb_journal.title] grid = SQLFORM.grid(query, fields = fields) Regards Johann Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)