我们有一个简单的模型:
class Post(models.Model):
created = models.DateField()
title = models.CharField(max_length=210)
content = models.TextField()
有没有办法用 Django ORM 实现 SQL 查询?
SELECT YEAR(created), COUNT(*)
FROM Post
GROUP BY YEAR(created)
我可以编写原始 SQL,但我想避免它......