Django: add new column by function ( datetimefield to datefield )

After lots of search i found my answer

from django.db.models.functions import TruncDate

Product.objects.annotate(day=TruncDate('date')).order_by('-day').distinct('day')

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top