When you create a reference field, if the referenced table has a "format" attribute, then the reference field will get a default IS_IN_DB validator (which is used to construct the SQLFORM dropdown) and a default "represent" attribute. Otherwise, you will have to create those yourself. So, just add a "format" to the device table definition.
Regarding wrong reference to foreign key, probably you are attempting to enter a value other than that of an existing "id" field in the db.device table. Anthony On Thursday, March 30, 2017 at 8:32:01 AM UTC-4, [email protected] wrote: > > Suppose i have 3 tables: > > db.define_table('testbed', > Field('name'), > Field('alias_name'), > > Field('author',db.auth_user,default=auth.user_id,readable=False,writable=False), > format='%(name)s') > > > db.define_table('device', > Field('name',unique=True,notnull=True), > Field('alias_name'), > Field('related_testbed','reference testbed')) > > > db.define_table('conn', > Field('IP'), > Field('Port'), > Field('related_device','reference device')) > > When trying to enter a record in table 'device' i am getting list drop > down which is giving option to select testbed name for field > 'related_testbed' because it is referencing to table 'testbed' but while > entering values for field 'related_device' in table 'conn' not getting any > drop down. and even if i am entering a value for that field then getting > the error "wrong reference to foreign key. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

