I have a Post
model that has a datetime.date
field for posted_date
. I need to find how many posts are made by a user on each day. Creating a query for each day seems silly.
I couldn't figure out how to make the aggregation API query using annotate.
Is
Post.objects.filter(author=someuser).annotate(dailycount=Count('posted_day'))
the correct way? Then, how do I use this to get number of posts for a particular day?
My model is:
class Post(models.Model):
posted_day=models.DateField(default=date.today)
author=models.ForeignKey(User,null=True)