Django Include Aggregate Sums of Zero

Posted by tomas on Stack Overflow See other posts from Stack Overflow or by tomas
Published on 2010-05-19T14:22:05Z Indexed on 2010/05/19 15:30 UTC
Read the original article Hit count: 225

Filed under:
|

I'm working on a Django timesheet application and am having trouble figuring out how to include aggregate sums that equal zero. If I do something like:

entries = TimeEntry.objects.all().values("user__username").annotate(Sum("hours"))

I get all users that have time entries and their sums.

[{'username': u'bob' 'hours__sum':49}, {'username': u'jane' 'hours__sum':10}]

When I filter that by a given day:

filtered_entries = entries.filter(date="2010-05-17")

Anyone who didn't enter time for that day is excluded. Is there a way to include those users who's sums are 0?

Thanks

© Stack Overflow or respective owner

Related posts about django

Related posts about django-aggregation