template = '%(function)s(%(what_to_extract)s FROM %(expressions)s)'
Comment.objects.annotate(year=Extract(date, what_to_extract='year'), month=
    Extract(date, what_to_extract='month')).values('year', 'month').annotate(
    Count('pk'))
Django count grouping by year/month without extra