I'd suggest something like this:

=== db.py ===
db.define_table('dish',
    Field('name'))

db.define_table('ingredient',
    Field('name'))

db.define_table('recipe',
    Field('dish', db.dish),
    Field('ingredient', db.ingredient),
    Field('quantity'))
    
ingredients_in_dish = db((db.dish.id==db.recipe.dish) &
        (db.ingredient.id==db.recipe.ingredient))

=== default.py ===
def index():
    recipes = ingredients_in_dish(db.dish.name=='Carrot Soup').select()
    return dict(recipes=recipes

=== index.html ===
<h1>{{=recipes[0].dish.name}}</h1>
<ul>{{for recipe in recipes:}}
    <li>{{=recipe.recipe.quantity}} - {{=recipe.ingredient.name}}</li>
{{pass}}
</ul>


Reply via email to