[web2py] Re: Table reference field instead of the id

2013-12-09 Thread Gael Princivalle
Well I've done it in another way: db.define_table('brands', Field('id_01', 'id'), # 'id' instead of unique = True Field('name'), format='%(names') db.define_table('products', Field('code', unique=True), Field('descripti

[web2py] Re: Table reference field instead of the id

2013-12-09 Thread Gael Princivalle
With your solution Field('id_01', 'id')now I can add a custom column in the grid with links (also without a link inside !): links = [dict(header=T('Brand'), body=lambda row: (db.brands(row.brand_id_01).name))] Ok, it works fine, but how can I display this custom column in my custom single vi

[web2py] Re: Table reference field instead of the id

2013-12-09 Thread Anthony
> > I cannot use web2py id's for referencing my brands, I need to use id's > from another CRM application called "01". So I have in my "brands" table a > field called "id_01" and in the "products" table a field called > "brand_id_01". > > db.define_table('brands', > Field('id

[web2py] Re: Table reference field instead of the id

2013-12-09 Thread Gael Princivalle
Thanks Massimo but with: links = [dict(header=T('Brand'), body=lambda row: (db.brands(row.brand_id_01).name))] it give me this error: 'NoneType' object has no attribute 'name' I've also tried with reference: db.products.brand_id_01.represent = lambda id,row: '%s' % db.brands[row.brand_id_01].

[web2py] Re: Table reference field instead of the id

2013-12-08 Thread Massimo Di Pierro
Try replace lambda row: (something that return the brands.name of the products.brand_id_01 current row) with lambda row: (db.brands (row.brand_id_01).name) On Sunday, 8 December 2013 11

[web2py] Re: Table reference field instead of the id

2013-12-08 Thread Gael Princivalle
Thanks Stifan but also with: db.products.brand_id_01.requires = IS_IN_DB(db, db.brands.id, '%(name)s') web2py don't display the "db.brands.name" instead of the "db.products.brand_id_01".. A solution could be make lambda function, what do you think about something like that ? In the controller: d

[web2py] Re: Table reference field instead of the id

2013-12-08 Thread 黄祥
i think you should refer it to db.brands.id. e.g. db.define_table('brands', Field('id_01', unique = True), Field('name'), format='%(name)s') db.define_table('products', Field('code', unique=True), Field('description'),