api.py 451 Bytes
import requests
from rest_framework.response import Response
from rest_framework.decorators import api_view

from django.conf import settings


@api_view(['POST'])
def recaptcha(request):
    r = requests.post(
        'https://www.google.com/recaptcha/api/siteverify',
        data={
            'secret': settings.SECRET_KEY_CAPTCHA,
            'response': request.data['captcha_value'],
        }
    )

    return Response({'captcha': r.json()})