Hello,
I have a model with 2 tables with a "reference" relationship between
the two.
=> the Budget has a type and the name/attributes of this type are
defined in the budget_types table.
Now in a query on the budget table i would like to retrieve the name
of the Budget type and not the Budget Type id.
My model is:
db.define_table('budget_types',Field('name','string'),Field('description','string'),format='%
(name)s')
db.define_table('budgets',Field('name','string'),Field('monthly_amount','double'),Field('type',db.budget_types),Field('view_order','integer'),format='%
(name)s')
My current query is :
budget_list=
db().select(db.budgets.id,db.budgets.name,db.budgets.type,db.budgets.monthly_amount,orderby=db.budgets.view_order).as_list()
I was thinking about doing
budget_list=
db().select(db.budgets.id,db.budgets.name,db.budgets.type.name,db.budgets.monthly_amount,orderby=db.budgets.view_order).as_list()
but it fails.
I guess i could do this with an explicit join but i thought there was
a "related" feature like in django ;-)