I have a model where roads are the base table. In a one to many relation I have intersection addresses and each address has many pieces of equipment.
Model looks like this # Road table, some winding roads are both street and avenue db.define_table('road', Field('name', 'string', length=32, unique=True, required=True, notnull=True, label='Road Name'), Field('is_street', 'boolean', default=False), Field('is_avenue', 'boolean', default=False), format='%(name)s' ) # Address table, the set_address_requirements allows lazy table definition and # makes sure 2 intersections are not entered through forms into the database def set_address_requirements(address): address.street_id.requires = IS_IN_DB(db(db.road.is_street == True), 'road.id', '%(name)s') address.avenue_id.requires = IS_IN_DB(db(db.road.is_avenue == True), 'road.id', '%(name)s', _and = IS_NOT_IN_DB(db(db.address.street_id==request.vars.street_id), 'address.avenue_id')) db.define_table('address', Field('street_id', "reference road", label='Street'), Field('avenue_id', "reference road", label='Avenue'), #format='%(street_id)s %(avenue_id)s', on_define=set_address_requirements ) db.define_table('equipment', Field('address_id', 'reference address', label='Address'), ... more fields related to equipment } The address table operates correctly showing road names in both a street and avenue drop down properly filtered when adding a new record to the address table. I want the equipment table address_id field to show the pair of road names not the ids. I think I need to find the correct format specifier which is commented out right now. I get the id values if I use it but have tried to find a way to get db.road.street_id.name which of course won't work, it is just for illustration of what I want. I am just using the admin dtabase interface to check it. Thanks, Ron -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.