On Mon, 2007-08-20 at 22:04 +0000, Djon wrote:
> Hi
> 
> My model is:
> 
> class Tag(models.Model):
>     name = models.CharField(maxlength=30)
> 
> class Snippet(models.Model):
>     name = models.CharField(maxlength=30)
>     tags =
> models.ManyToManyField(Tag,filter_interface=models.HORIZONTAL)
> 
> My aim to filter snippets according to multiple tag constraints
> simultaneously.
> However, the overlap of two sets just doesn't get filtered properly.
> E.g.:
> 
> In [96]: Snippet.objects.filter(tags__name="home")
> Out[96]: [<Snippet: clean home>, <Snippet: email from home>]
> 
> In [97]: Snippet.objects.filter(tags__name="email")
> Out[97]: [<Snippet: email from home>, <Snippet: email from work>]
> 
> In [98]:
> Snippet.objects.filter(tags__name="home").filter(tags__name="email")
> # SHOULD return [<Snippet: email from home>]
> Out[98]: []
> 
> I tried the exact same idea by using .filter(Q(..),Q(..)) and also
> with the Q(..)&Q(..) option, as well as by dividing the process into
> stages and inspecting the first filter's result on the way (it's
> valid). Everything just ends up with the same empty list...

It's a known bug. The SQL query that is constructed doesn't work with
many to many fields. Work in progress.

Regards,
Malcolm

-- 
If Barbie is so popular, why do you have to buy her friends? 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to