[Django]-How to write Django QuerySet to get UNIX_TIMESTAMP of a DateTimeField?

4👍

Look at func-expressions

from django.db.models import Func, F, Sum

queryset.annotate(sum=Sum(Func(F('my_date'), function='UNIX_TIMESTAMP')))

Leave a comment