Closed hemache closed 6 years ago
I spoke about this issue with @dermoumi. He suggested that I use a property instead, which seams to work pretty fine.
yep, as long as we don't actually store the count in a database column.
side question, why not return self.comment_set.count()
instead of Comment.objects.filter(topic=self).count()
?
fixed, used the related_name=comments
in the definition of the comment model and replaced Comment.objects.filter(topic=self).count()
with self.comments.count()
why not rely on dynamic counting using Django ORM, something like