@require_GET
@csrf_exempt
@json_response
def comment_count(request):
    domain = request.GET.get('domain', None)
    thread_url = request.GET.get('thread_url', None)

    try:
        site = Site.objects.get(domain=domain)
    except Site.DoesNotExist:
        return HttpResponseBadRequest(
            _('site with domain %s not found') % domain
        )

    try:
        thread = site.threads.get(url=thread_url)
    except Thread.DoesNotExist:
        return HttpResponseBadRequest(
            _('thread with url %s not found') % thread_url
        )

    comment_count = thread.comments.filter(hidden=False).count()

    return {"comment_count": comment_count}
dataset/ETHPy150Open c4all/c4all/comments/views.py/comment_count/original