>
> db.sessions.client_id.requires = IS_IN_DB(db, db.clients.id, '%(name)s')
>
>
No, as I mentioned, you should *not* explicitly define the IS_IN_DB
validator. You will get one automatically when you create a reference
field. If the referenced table has a "format" attribute, then that format
attribute will be used both in the reference field's IS_IN_DB validator and
as the "represent" attribute for the reference field. However, if you
explicitly define an IS_IN_DB validator, then you no longer get a default
"represent" attribute, and you therefore also have to explicitly define
that attribute as well. So, either get rid of your IS_IN_DB, or add the
following:
db.define_table('sessions',
Field('client_id', db.clients,
requires=IS_IN_DB(db, db.clients.id, '%(name)s'),
represent=lambda id, row: db.clients(id).name))
There's no need for the above, though, as this will get you the equivalent
by default (as long as you have the "format" attribute defined in the
db.clients table):
db.define_table('sessions',
Field('client_id', db.clients))
Anthony