I've got a bunch of Order objects, each connected to one or more OrderRow objects (visible as a reverse relation to their parent Orders with Order.order_rows.all()).
Each OrderRow has a collection_status attribute, which can be 'collected', 'uncollected' or a bunch of other special values. Each Order has a status attribute, one of the valid values being 'processing'.
I'm at a loss trying to build an Order QuerySet that lists Order objects with the following criteria: Order status is 'processing', the count of its collection_status='collected'
OrderRows is less than the total count of its OrderRows. Orders that have been not at all collected or partially collected, but not fully collected, that is.
To put it in an explicit way:
Order with two rows, both 'uncollected': included in the QS
Order with three rows, one 'collected', two 'uncollected': included in the QS
Order with two rows, both 'collected': NOT included in the QS!
(You can replace 'uncollected' with any other value that isn't 'collected' and the criteria is still the same; it's 'collected' vs. any other collection_status)
I've gotten as far as Order.objects.filter(status__exact='processing'), but beyond that, all my attempts at annotations, Q() objects etc. have failed miserably.