Oops... replied to wrong thread...

here it is...

It has a lot of stuff... but the core is simple enough, like this...

class Product(models.Model):
        title =  models.CharField(maxlength=200, db_index=True)
        url = models.URLField(maxlength=250, db_index=True, unique=True)
                        

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


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


...

At the moment I'm naving to do this...

q = Product.objects.all()
wordobj = Word.objects.get(value=word)
productwords = wordobj.productword_set.all()[:]

id_list = [ ]           
for pw in productwords:
        id_list.append(pw.fk_product.id)

q =  q.filter(   id__in=id_list   )

...which is clunky isn't it? I think django then goes off and does  
one query per item in id_list and joins the results anyway...

regards

tom

--~--~---------~--~----~------------~-------~--~----~
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