I think you are asking about this:
db.define_table(
'manufacturer',
Field('name'),
format = '%(name)s')
db.define_table(
'model',
Field('manufacturer', db.manufacturer),
Field('model'),
format=lambda r: '%s %s' % (r.manufacturer.name, r.model)) # one hidden
query
db.define_table(
'shoe',
Field('model',db.model),
Field('purchased','date'),
Field('price','integer'),
format=lambda r: '%s %s' % (r.model.manufacturer.name,r.purchased)) # 2
hidden queries
On Thursday, 1 January 2015 16:25:10 UTC-6, Gary Cowell wrote:
>
> I want the 'format' for the dropdown when I create a 'run' entry to be '
> manufacturer.name model.model shoe.purchased'
>
> e.g. 'Mizuno Wave Rider 10-11-2014' for instance where 'Mizuno' is the
> manufacturer name, 'Wave Rider' is the model.model, and the date is
> shoe.purchased
>
> I managed to get the 'shoe' table definition to represent the model and
> date with a lambda, but I don't know how to include the manufacturer name
> from the 'model' table parent.
>
> So the question is, how do I change the lambda on the 'shoe' table to pull
> entries from its parent, and grandparent? I only managed the parent table
> so far.
>
> Thank you
>
> Here are my models:
>
> db.define_table(
> 'manufacturer',
> Field('name'),
> format = '%(name)s')
>
> db.define_table(
> 'model',
> Field('manufacturer', db.manufacturer),
> Field('model'),
> format=lambda r: '%s %s' % (db.manufacturer[r.manufacturer].name,
> r.model))
>
> db.define_table(
> 'shoe',
> Field('model',db.model),
> Field('purchased','date'),
> Field('price','integer'),
> format=lambda r: '%s %s' % (db.model[r.model].model,r.purchased))
>
>
> db.define_table(
> 'run',
> Field('run_date','date'),
> Field('run_time','time'),
> Field('run_event'),
> Field('run_distance','integer'),
> Field('run_calories','integer'),
> Field('shoe',db.shoe),
> Field('race','boolean'),
> format = '%(rundate)')
>
--
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.