How can I display total likes per month of an post to the author on Django
I want to display total likes a author got on his post on monthly basis in Django. For eg: On january total likes of his post is like 100
def total_contents(self):
total_likes_received = post.objects.filter(author=self.request.user).count()
return total_likes_received
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['total_contents'] = self.total_contents()
return context
This is my views.py but this code will return total post he posted on the website. I want to return total likes he go on his post per month on Django
class blogs(models.Model):
title = models.CharField(max_length=100, null=True, blank=True)
slug = models.SlugField(max_length=200, unique=True, auto_created=True)
author = models.ForeignKey(User, on_delete=models.CASCADE)
created_on = models.DateField(auto_now_add=True)
time = models.TimeField(auto_now=True)
likes = models.ManyToManyField(User, related_name='likes', blank=True)
liked = models.BooleanField(default=False)
like_count = models.BigIntegerField(default=0)
post = models.TextField(max_length=200 )