Hello,
I am trying to find how to filter the entries of my blog by a set of
tags, using the Django models.
In particular there are two relations:
Blog (id, title, content)
Tag ( name, blog_id )
with Tag.blog_id foreign key of Blog.id
I want to select all blog entries that contain a certain set of tags.
For instance, I would express the query in SQL as:
SELECT * FROM blog_blog b WHERE EXISTS ( SELECT 1 FROM blog_tag t WHERE
t.blog_id = b.id AND lower(t.name) IN ('tag1', 'tag2', 'tag3')  );

How to represent the same query with the Django QuerySets ?

Thanks,
Dean De Leo


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54D78EFA.4030302%40gmx.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to