Hey, I have a many-to-manyrelation, such as:
*db.define_table('product_tag', Field('product', 'reference
product'), Field('tag', 'reference tag'), )*
Now when I would like to select the tags for a product with the id
row.product.id, I came up with this, so that I don't have to do an extra
query for each tag name:
*dbTags =
db(db.product_tag.product==row.product.id).select(join=db.tag.on(db.tag.id==db.product_tag.tag))*
Now when I iterate dbTags, I don't need to reference the product_tag table,
but only the tag table. I would like to iterate such as
*for tag in dbTags: print tag.name # instead of current tag.tag.name*
Thanks for your help!
--
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.