擅长:python、mysql、java
<p>既然<code>Extra()</code>正在贬值,一个更合适的答案将使用<a href="https://docs.djangoproject.com/en/1.10/ref/models/database-functions/#trunc" rel="noreferrer">Trunc</a>,例如<a href="https://stackoverflow.com/questions/8746014/django-group-by-date-day-month-year">this accepted answer</a></p>
<p>现在操作人员的问题将被回答如下</p>
<pre><code>from django.db.models.functions import TruncDay
Review.objects.all()
.annotate(date=TruncDay('datetime_created')
.values("date")
.annotate(created_count=Count('id'))
.order_by("-date")
</code></pre>