Hi Vitor,
Sorry I realized that my example should have used a ManyToManyField instead of a 1-to-many. Let me try again:
class Bundle(Model)
items = ManyToManyField("Item")
class Item(Model)
pass
(So one item can belong many Bundles and one Bundle can have many Items.)
Suppose I've created items item1, item2, item3 and I have special_items = [item1, item2]. Suppose also the following Bundles exist in the database:
1. Bundle containing item1
2. Bundle containing item2
3. Bundle containing item1, item2
4. Bundle containing item2, item3
5. Bundle containing item1, item2, item3
I want to select all bundles where *every item in the bundle* is in special_items. This means selecting bundles 1, 2, 3 but not bundles 4, 5 (because item3 is not in special_items).
The query you gave would select no bundles, and the query Bundle.objects.filter(items__in=[special_items]) would select all the bundles.
Dave