My model is like this...

class Product(models.Model):
        <snip>

class Word(models.Model):
        value =  models.CharField(maxlength=200, core=True, unique=True)

class  ProductWord(models.Model):
        fk_word = models.ForeignKey(Word , core=True)
        fk_product = models.ForeignKey(Product)

-----------------------------

And I need to be able to find products that have a certain  
productword.fk_word -> word.value ( I have created the ProductWord  
table because both __icontains and REGEXP are way too slow)

I can sort of get a list of products like this...

 >>> w = Word.objects.get(value='thomas')
 >>> w
  <Word: thomas>
 >>> productwords = ProductWord.objects.filter(fk_word=w)
 >>> productwords
  [<ProductWord: ProductWord object>, <ProductWord: ProductWord  
object>, <ProductWord: ProductWord object>, <ProductWord: ProductWord  
object>]

and then...

 >>>productwords[0].fk_product.title
'Thomas & Friends - Thomas and the School Trip - My First LeapPad  
Interactive Book'

BUT... this is a list of ProductWord objects... which is no good, I  
want a list of the Product objects... so how do I construct the query  
that starts like this...

  w = Word.objects.get(value='thomas')

and then goes to do this...

products = Product.objects.filter(   --->JOIN PRODUCTWORD.FK_PRODUCT  
= PRODUCT.ID
AND
WORD= PRODUCTWORD.FK_WORD <--- )

Big thanks to anyone who can help, I have read and re-red the  
documentation and just can't make sense of it...






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to