The join is making that happen. Why not just do *dbTags =
db(db.product_tag.product==row.product.id
<http://row.product.id/>).select(db.product_tag.tag)*
*Whats the point in the join on a m2m table?*
On Tuesday, June 3, 2014 3:54:52 AM UTC-5, Robin Manoli wrote:
>
> 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
> <http://row.product.id>).select(join=db.tag.on(db.tag.id
> <http://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 <http://tag.name> # instead of
> current tag.tag.name <http://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.