Hello!

Assuming the following data model:

+------+                +------+                   +-----+
| Blog | has many (1:n) | Post | tagged with (n:m) | Tag |
+------+                +------+                   +-----+

I want to filter out all blogs that have a post tagged with "foo" and "bar" (the same post satisfying *both* conditions).

How would that query look like? Intuitively I'd say

    Blog.objects.filter(post__tags__name="foo",
                        post__tags__name="bar")

but obviously that's a SyntaxError because of the repeated keyword argument to filter(). I also tried Q() objects but that generates some totally unrelated queries.

The docs only have an example with two conditions against different fields (in topics/db/queries:"Spanning multi-valued relationships").

Thanks!
Jonas

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to