How To Write Django Queryset To Get Unix_timestamp Of A Datetimefield?
This question is a follow-up to the one here. Suppose I have the following Django model: from django.db import models from django.db.models import Sum class myModel(models.Model):
Solution 1:
Look at func-expressions
from django.db.models import Func, F, Sum
queryset.annotate(sum=Sum(Func(F('my_date'), function='UNIX_TIMESTAMP')))
Post a Comment for "How To Write Django Queryset To Get Unix_timestamp Of A Datetimefield?"