def get_dates_only(self):
""" Returns the queryset containing entries having the date field only.
Date is a trunc of a published_parsed datetime field.
"""
# NOTE: order_by influences the distinct() results here
date_times = RssNotification.objects.annotate(
published_parsed_date=Trunc('published_parsed', 'day', output_field=DateField()),
plain_field=F('published_parsed')
).values(
'published_parsed_date'
).distinct().filter(plain_field__isnull=False).order_by(
'-published_parsed_date'
).annotate(dates_count=Count('published_parsed'))
return date_times
评论列表
文章目录