[web2py] Re: How to select a table and represent the foreign key values

2018-03-29 Thread Greenpoise
sorry if you copied and pasted my solution, it had a typo. This worked for me: db.define_table('table1', Field('field_1'), format='%(field_1)s') db.define_table('table2', Field('field_1', 'reference table1'), Field('field_2', 'string'),

[web2py] Re: How to select a table and represent the foreign key values

2018-03-29 Thread LoveWeb2py
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. > >

[web2py] Re: How to select a table and represent the foreign key values

2018-03-29 Thread LoveWeb2py
Thank you so much for your help. db.table2.field_1.requires = 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

[web2py] Re: How to select a table and represent the foreign key values

2018-03-29 Thread Greenpoise
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')

[web2py] Re: How to select a table and represent the foreign key values

2018-03-29 Thread Greenpoise
db.table2.field_1.requires = 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

[web2py] Re: How to select a table and represent the foreign key values

2018-03-29 Thread LoveWeb2py
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 > (db,db.table_1.field_1,'%(field_1)s') > > > On Thursday,