I found that by adding db.table2.field_1.represent = lambda id, row: db.table1(row.field_1).field_1 db(db.table1).select().render()
It accomplishes the task. Thank you so much! On Thursday, March 29, 2018 at 1:56:14 PM UTC-4, LoveWeb2py wrote: > > Thank you so much for your help. > > db.table2.field_1.requires = IS_IN_DB > <http://localhost:8000/examples/global/vars/IS_IN_DB>(db,db.table_1. > field_1,'%(field_1)s') > rows = db(db.table1).select() > > rows shows db.table1 = 1 and not 'some_value' > > Unfortuantely still does not work. I am running pyDal on its own and when > I try to query the run > > On Thursday, March 29, 2018 at 12:50:45 PM UTC-4, Greenpoise wrote: >> >> Like this, in the model: >> db.define_table('table1', >> Field('field_1'), >> format='%(field_1)s') >> >> db.define_table('table2', >> Field('field_1', 'reference table1'), >> Field('field_2', 'string), >> format='%(field_1)s') >> db.table2.field_1.requires = IS_IN_DB >> <http://localhost:8000/examples/global/vars/IS_IN_DB>(db,db. >> table_1.field_1,'%(field_1)s') >> >> >> >> >> >> On Thursday, March 29, 2018 at 9:29:35 AM UTC-7, LoveWeb2py wrote: >>> >>> Do I define that in the model.py file? Can I do it before the query? >>> >>> On Thursday, March 29, 2018 at 12:28:02 PM UTC-4, Greenpoise wrote: >>>> >>>> db.table2.field_1.requires = IS_IN_DB >>>> <http://localhost:8000/examples/global/vars/IS_IN_DB>(db,db.table_1.field_1,'%(field_1)s') >>>> >>>> >>>> On Thursday, March 29, 2018 at 9:20:34 AM UTC-7, LoveWeb2py wrote: >>>>> >>>>> >>>>> How can I select a foreign key and represent the value? I want to >>>>> represent the entire group and now have to do individual queries for each >>>>> foreign key. Is that possible? >>>>> >>>>> db.define_table('table1', >>>>> Field('field_1'), >>>>> format='%(field_1)s') >>>>> >>>>> db.define_table('table2', >>>>> Field('field_1', 'reference table1'), >>>>> Field('field_2', 'string), >>>>> format='%(field_1)s') >>>>> >>>>> So in this example I would do data = db(db.table1).select() which >>>>> returns a rows object. But the reference table1 returns an integer >>>>> instead >>>>> of the actual value stored in the field. >>>>> >>>>> How could I retrieve the value instead of the integer and is it >>>>> possible to do it in bulk? >>>>> >>>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.