I\'m trying to filter users by date, but can\'t until I can find the first and last date of users in the db. While I can have my script filter out dups later on, I want to do it
When doing reports on larger datasets itertools.group_by might be too slow. In those cases I make postgres handle the grouping:
itertools.group_by
truncate_date = connection.ops.date_trunc_sql('day','timestamp') qs = qs.extra({'date':truncate_date}) return qs.values('date').annotate(Sum('amount')).order_by('date')