I have a function that looks like this:
def post_count(self):
return self.thread_set.aggregate(num_posts=Count(\'post\'))[\'num_posts\']
<
I have been looking into something similar and have not found a great solution. I'm using something like this:
def post_count(self):
return len(Post.objects.filter(someModel = self).filter(active_status = 1))
It's not great, but I don't think that Django allows you to filter based on the secondary model aggregations and annotations. I'll be checking to see if anyone comes up with a better solution.