Groups
Groups
Sign in
Groups
Groups
Django users
Conversations
About
Send feedback
Help
many-to-many relation field__in - how to AND instead of OR?
0 views
Skip to first unread message
anentropic
unread,
Nov 25, 2009, 6:57:17 AM
11/25/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
I have a query like:
Product.objects.filter(categories__in=cat_ids).distinct()
where categories is a m2m field.
As I understand it this loads products which have belong to ANY of the
categories in cat_ids
How would I load only products which belong to ALL of the categories
in cat_ids?
(is this possible in ORM?)
I think in SQL you'd have to change the one IN clause to a series of
ANDs
Reply all
Reply to author
Forward
0 new messages