docs: def comment(request, template="generic/comments.html", extra_context=None):
      """
      Handle a ``ThreadedCommentForm`` submission and redirect back to its
      related object.
      """
      response = initial_validation(request, "comment")
      if isinstance(response, HttpResponse):
          return response
      obj, post_data = response
      form_class = import_dotted_path(settings.COMMENT_FORM_CLASS)
      form = form_class(request, obj, post_data)
      if form.is_valid():
          url = obj.get_absolute_url()
          if is_spam(request, form, url):
              return redirect(url)
          comment = form.save(request)
          response = redirect(add_cache_bypass(comment.get_absolute_url()))
          # Store commenter's details in a cookie for 90 days.
          for field in ThreadedCommentForm.cookie_fields:
              cookie_name = ThreadedCommentForm.cookie_prefix + field
              cookie_value = post_data.get(field, "")
              set_cookie(response, cookie_name, cookie_value)
          return response
      elif request.is_ajax() and form.errors:
          return HttpResponse(dumps({"errors": form.errors}))
      # Show errors with stand-alone comment form.
      context = {"obj": obj, "posted_comment_form": form}
      context.update(extra_context or {})
      return TemplateResponse(request, template, context)