Thanks Simon, that's exactly what I needed. I had read the aggregation
documentation, but hadn't figured out how to get it to do what I needed.
Cheers,
Malcolm
On Friday, 20 May 2016 16:52:01 UTC+1, Simon Charette wrote:
>
> Hi Malcom,
>
> I suggest you look into the conditionnal aggregation do
Hi Malcom,
I suggest you look into the conditionnal aggregation documentation[1].
from django.db.models import Case, Count, When
Contact.objects.annotate(
messages_count=Count(
Case(When(
messages__recipient=recipient,
messages__status=Message.STATUS_UNREAD,
2 matches
Mail list logo