I have the following table:
2018-01-01 10
2018-01-15 20
2018-01-31 30
2018-02-01 10
2018-03-01 10
2018-03-20 20
I need to Sum() the values filtering it with
1 - sum(values) where date < first day of the month
2 - sum(values) where date < last day of the month
Expec
I have the following:
In [39]: from django.db.models.functions import TruncDate
...: p = Purchase.objects \
...: .annotate(date=TruncDate('event_date')) \
...: .values('date') \
...: .annotate(total=Sum('quantity')) \
...: .order_by('event_date')
...:
.
I am using USE_TZ = True and TIME_ZONE = 'America/Sao_Paulo' when I save
some datetime field it will save on MySQL in UTC as expected, but when I
query this object and print object.date it still in UTC, I tried to set
timezone.activate(timezone.get_default_timezone()) before querying but the
r
3 matches
Mail list logo