{"id":23632,"library":"drf-recaptcha","title":"DRF reCAPTCHA","description":"A Django REST Framework field and serializer for Google reCAPTCHA (v2 and v3) verification. Current version 4.0.3 supports Django ≥4.2, Python ≥3.10, DRF ≥3.14. Released irregularly; latest updates add Django 5.2 and Python 3.13 support.","status":"active","version":"4.0.3","language":"python","source_language":"en","source_url":"https://github.com/llybin/drf-recaptcha","tags":["django","django-rest-framework","recaptcha","serializer","captcha"],"install":[{"cmd":"pip install drf-recaptcha","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"Core dependency for web framework","package":"django","optional":false},{"reason":"Required for serializer field integration","package":"djangorestframework","optional":false},{"reason":"Used to verify reCAPTCHA with Google's API","package":"requests","optional":false}],"imports":[{"wrong":"from drf_recaptcha.serializers import ReCaptchaSerializer","symbol":"ReCaptchaSerializer","correct":"from drf_recaptcha import ReCaptchaSerializer"}],"quickstart":{"code":"import os\nfrom django.conf import settings\nfrom rest_framework import serializers\nfrom drf_recaptcha.serializers import ReCaptchaSerializer\n\nsettings.configure(\n    DRF_RECAPTCHA_SECRET_KEY=os.environ.get('RECAPTCHA_SECRET_KEY', 'test-secret'),\n    INSTALLED_APPS=['django.contrib.contenttypes', 'django.contrib.auth'],\n    DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}},\n)\nimport django\ndjango.setup()\n\nclass MySerializer(ReCaptchaSerializer):\n    email = serializers.EmailField()\n\n# Dummy data for testing (use valid reCAPTCHA response in production)\ndata = {'email': 'test@example.com', 'recaptcha': 'dummy-response'}\nserializer = MySerializer(data=data)\nprint(serializer.is_valid())","lang":"python","description":"Quickstart: define a serializer inheriting ReCaptchaSerializer. Configure DRF_RECAPTCHA_SECRET_KEY in Django settings. For testing, set DRF_RECAPTCHA_TESTING=True to bypass verification."},"warnings":[{"fix":"Ensure Django ≥4.2, Python ≥3.10, DRF ≥3.14 before upgrading to drf-recaptcha ≥4.0.","message":"Version 4.0.0 drops support for Django 3.2, 4.0, 4.1; Python 3.8, 3.9; and DRF 3.11, 3.12, 3.13. Upgrade your environment if migrating from <4.0.","severity":"breaking","affected_versions":"<4.0"},{"fix":"Add `Meta.exclude = ['recaptcha']` or use `fields` to limit output fields.","message":"The `ReCaptchaSerializer` includes a `recaptcha` field by default but does not hide it from the serializer output. This field will be serialized back to the client unless explicitly excluded using `exclude` or `fields`.","severity":"gotcha","affected_versions":"All"},{"fix":"Upgrade to ≥3.2.0 if you need a required score of 0. Now a score of 0 correctly allows all traffic.","message":"In reCAPTCHA v3, the default required score is 0.5. Setting the required score to 0 (to allow all) was broken before version 3.2.0; the score 0 was treated as None and overridden to 0.5.","severity":"gotcha","affected_versions":"<3.2.0"},{"fix":"Use `DRF_RECAPTCHA_TESTING=True` only in test environments; for real bypass consider using a mock serializer.","message":"The setting `DRF_RECAPTCHA_TESTING` when set to `True` skips actual verification. However, the field will still require a non-empty string. This is intended for testing but may confuse users expecting full bypass.","severity":"deprecated","affected_versions":"All"},{"fix":"Always pass the intended secret key explicitly when using multiple keys: `ReCaptchaField(secret_key='...')`.","message":"Multiple/ dynamic secret keys (introduced in 3.0.0) require passing a secret key via the serializer's `context` or field kwargs. If not provided, the default `DRF_RECAPTCHA_SECRET_KEY` is used. Forgetting this can lead to wrong key usage.","severity":"gotcha","affected_versions":"≥3.0.0"}],"env_vars":null,"search_vec":"'3.10':24 '3.13':36 '3.14':26 '4.0.3':19 '4.2':22 '5.2':33 'add':31 'captcha':45 'current':17 'django':4,21,32,38,40 'django-rest-framework':39 'drf':1,25 'field':7 'framework':6,42 'googl':11 'irregular':28 'latest':29 'python':23,35 'recaptcha':2,12,43 'releas':27 'rest':5,41 'serial':9,44 'support':20,37 'updat':30 'v2':13 'v3':15 'verif':16 'version':18","created_at":"2026-05-01T08:08:47.852166+00:00","updated_at":"2026-05-01T08:08:47.852166+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'ReCaptchaSerializer' from 'drf_recaptcha' (/tmp/tmpnhw11fky/venv/lib/python3.12/site-packages/drf_recaptcha/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.0.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/llybin/drf-recaptcha","docs":null,"changelog":null,"pypi":"https://pypi.org/project/drf-recaptcha/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","auth-security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}