text: from django.conf import settings
  
  import requests
  
  
  def check_recaptcha(func):
      def wrap(request, *args, **kwargs):
          request.recaptcha_is_valid = None
          if request.method == "POST":
              recaptcha_response = request.POST.get("recaptcha")
              data = {
                  "secret": settings.GOOGLE_RECAPTCHA_SECRET_KEY,
                  "response": recaptcha_response,
              }
              req = requests.post("https://www.google.com/recaptcha/api/siteverify", data=data)
              response = req.json()
              if response["success"]:
                  request.recaptcha_is_valid = True
              else:
                  request.recaptcha_is_valid = False
          return func(request, *args, **kwargs)
  
      wrap.__doc__ = func.__doc__
      wrap.__name__ = func.__name__
      return wrap
  