I have a model with a typical ManyToManyField defined. Now, I can
filter on any one value in the  list of values it contains, or OR them.
But I cannot AND them.

Example (I hope this is clear):

Filter on one particular entry ID in the target table:

Python> models.QueryTerm.objects.filter(Q(classifications=4))
[<QueryTerm: linux (en)>, <QueryTerm: movie about linux (en)>]

gets two resutls, filter on another entry ID in the target:

Python> models.QueryTerm.objects.filter(Q(classifications=6))
[<QueryTerm: movie about linux (en)>]

Get the one (known) result.

I an OR them, to get the superset:

Python> models.QueryTerm.objects.filter(Q(classifications=6)|
Q(classifications=4))
[<QueryTerm: linux (en)>, <QueryTerm: movie about linux (en)>,
<QueryTerm: movie about linux (en)>]

But if I AND them (here is the problem/question), nothing...

Python> models.QueryTerm.objects.filter(Q(classifications=6) &
Q(classifications=4))
[]

But I expect to get the object that has in its M2M relation both of
these (there is one).

So, is this a bug? Or am I doing something wrong?


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