Hi Iain,
I think you could do something like this.
the_category = Category.byName("somename") # for this you would need
to make the name an alternate id
# or
the_category = Category.select(Category.q.name == "somename")[0]
products = Product.select( Product.q.category == the_category)
Igor
On 19-Nov-06, at 3:06 AM, iain duncan wrote:
>
> I looked through the SO docs for this, but well, it's a bit "terse"
> shall we say.
>
> I have a product table, a category table, and a many-to-many product
> category table created by SO because of the related join clause in my
> model. What I can't figure out how to do properly is select all the
> products that have a category. ie:
>
> products = Product.select( categories voo doo here? )
>
> If someone can give me a tip before I start handwriting queries
> ( which
> at least I know how to make work! ) that would be wonderful. =)
>
> Models in question:
>
> class Product(SQLObject):
> name = StringCol( length=100 )
> description = StringCol()
> # tag for default ordering before sorting
> ordering = IntCol()
> price = CurrencyCol()
> pst = BoolCol( default=False )
> gst = BoolCol( default=True )
> shipping = CurrencyCol( default=0.00 )
> discountable = BoolCol( default=False )
>
> categories = RelatedJoin('Category')
>
>
> class Category(SQLObject):
> name = StringCol( length=100 )
> description = StringCol()
> ordering = IntCol()
>
> products = RelatedJoin('Product')
>
> Thanks ever helpful list!
> Iain
>
>
>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---