I think you have a mistake in your requires : db.purchases.name.requires = IS_IN_DB(db,db.customers*.id*,'%(name)s')
In purchases name you should have a id (an integer), so then you can use represent : db.purchases.name.represent = lambda id, row: db.auth_user(id).name if id!=None else 'N/A' # the if is needed if you plan to use empty_or(is_in_db... Then if you make a query for data from purchase you will get : Jack, CD John, DVD Instead of the id like pbreit was showing... 1, CD 2, DVD Richard On Wed, Feb 8, 2012 at 1:58 AM, pbreit <[email protected]> wrote: > I'm not sure that reference is going to work. The reference usually points > to the "id". So: > > db.define_table('customers', > Field('name'), > Field('age'), > format = '%(name)s' > ) > > db.define_table('purchases', > Field('customer_id', db.customers), > Field('cart') > ) > > Then the query might be: > > rows = db((db.purchases.id>0)&(db.purchases.customer_id==db.customers.id > )).select() > > The purchases table would need to look like: > (1, CD) > (1, DVD) > > Web2py automatically makes the first column in all tables an > auto-incrementing field named "id". >

