db.define_table('clients',
Field('number'),
Field('name'),
format='%(name)s')
Then you don't have to explicitly define the IS_IN_DB validator, as
sessions.client_id will get one by default with the format set to the
db.clients format attribute. In that case, the sessions.client_id represent
attribute will also be set to the db.clients format attribute.
Anthony
On Monday, July 9, 2012 8:35:41 AM UTC-4, Remco K wrote:
>
> Hi everyone,
>
> I'm working with SQLFORM.grid but I cant get the referenced table
> representation to work. The only thing i get is the ID of the referenced
> table(s):
>
> *db.py: *
> db.define_table('clients',
> Field('number'),
> Field('name')
> )
>
> db.define_table('sessions',
> Field('client_id', db.clients),
> Field('state')
> )
>
> db.sessions.client_id.requires = IS_IN_DB(db, db.clients, '%(name)s')
>
> *controller:*
> fields = (db.sessions.client_id)
> headers = {'sessions.client_id':"Client"}
>
> _form = SQLFORM.grid(db.sessions.id>0 ,fields=fields,
> headers=headers,maxtextlength
> =500)
> *
> I get:*
> Client
> 111
>
> *Instead of:*
> Client
> <client.name>
>
> I've Googled for a while but i cant find any solution yet.
>
> The version of Web2Py i'm using:
>
> Version 2.0.0 (2012-06-29 20:55:40) dev
>
> Thanks in advance!Remco
>