code: def comment_count(object):
      
      return Comment.objects.filter(
          object_id=object.pk,
          content_type=ContentType.objects.get_for_model(object)
      ).count()
docs: Usage:
          {% comment_count obj %}
      or
          {% comment_count obj as var %}