Hello Anthony, Indeed, inserting using the web2py grid or SQLFORM does have the drop-down with the tier name rather than the IDs. I wanted to avoid the operation of looking up the tier_id because I thought there was a way to reference by name. The lookup will do. Thank you for your help!
On Wednesday, May 28, 2014 6:49:41 AM UTC-5, Anthony wrote: > > How are you inputting records into db.metrics? If via a web2py grid or > SQLFORM, the drop-down will have the tier names rather than the IDs (due to > the fact that you have specified format='%(name)s'). If you need to do > inserts programmatically outside of a form, you can just do a lookup in the > db.tiers table: > > tier_id = db.tiers(name='some name') > > Anthony > > On Tuesday, May 27, 2014 8:35:43 PM UTC-4, Michael Gheith wrote: >> >> I have two pretty basic tables: >> >> db.define_table('tiers', >> Field('name', 'string'), >> Field('created_on', 'datetime', default=request.now), >> format = '%(name)s') >> >> db.define_table('metrics', >> Field('tier_id', 'reference tiers'), >> Field('total_count', 'integer'), >> Field('total_size', 'bigint'), >> Field('created_on', 'datetime', default=request.now)) >> >> I pre populated my tiers table with data. When I store data in my >> metrics table, I don't know off hand the tier_id. I know the tier name >> though. Is there a way I can use the tier name instead of the tier_id in >> this reference? >> > -- 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.