Please look into the following code: db = DAL("sqlite://storage.sqlite")
from gluon.tools import * auth = Auth(db) auth.define_tables() crud = Crud(db) db.define_table('country', Field('name', unique=True), format = '%(name)s') db.define_table('state', Field('country_id', db.country), Field('name', unique=True), format = '%(name)s') class StateVirtualFields(object): def namecountryid(self): return str(self.state.country_id)+self.state.name db.state.virtualfields.append(StateVirtualFields()) db.define_table('city', Field('state_id', db.state), Field('name', unique=True), format = '%(name)s') db.country.name.requires = IS_NOT_IN_DB(db, db.country.name) db.country.name.requires = IS_NOT_EMPTY() db.state.name.requires = IS_NOT_IN_DB(db, db.state.name) db.state.name.requires = IS_NOT_EMPTY() #db.state.country_id.writable = db.state.country_id.readable = False db.state.country_id.requires = IS_IN_DB(db, db.country.id, '%(name)s') db.state.namecountryid.requires = IS_NOT_IN_DB(db, db.state.namecountryid) Last statement does not work. Please help. Suresh