Hmm.. I've actually declared fields of type 'integer', then declare a validator field much later in the code. Often in a custom auth_user fields that needs to refer to tables which will be defined much later. Kinda makes it like a pseudo-reference field.
Field('account_status', 'integer')# custom auth_user field db.define('some_table', Field('name')) db.auth_user.account_status.requires=IS_IN_DB(db, 'some_table.id', '%name') Hmm.. come to think of it maybe this is possible... db.auth_user.account_status.type='reference some_table' On Friday, December 16, 2011, Anthony wrote: > On Thursday, December 15, 2011 11:42:42 AM UTC-5, thodoris wrote: >> >> This is a solution but look at the following, if i declare >> >> >> db.define_table('person', >> Field('name'),) >> >> db.define_table('cat', >> Field('name'), >> Field('owner',"integer",db.**person,default=db.person.id)) >> db.cat.owner.requires = IS_IN_DB(db, db.person.id) >> the reference is broken. Is there another solution? >> > > If you want 'owner' to reference the 'person' table, then make it a > 'reference' field type, not 'integer': > > Field('owner', db.person) > > or > > Field('owner', 'reference person') > > Note, you can't set the default to db.person.id because that refers to > the 'id' field of the 'person' table, not a specific value for a given > person. > > Anthony >