Skip to main content
Django Rest reCAPTCHA
================
**Django Rest reCAPTCHA field to add google recaptcha in django-rest-framework**


Requirements
------------

Tested with:

* Python: 2.7, 3.5
* Django: 1.8, 1.9, 1.10, 1.11

Installation
------------

#. Install with ``pip install django-rest-recaptcha``.

#. Add ``'recaptcha'`` to your ``INSTALLED_APPS`` setting.

#. Register and obtain recaptcha keys here `https://www.google.com/recaptcha/admin`

#. Add the obtained keys to settings(For testing and development you can leave it blank to use
default test keys as mentioned here `https://developers.google.com/recaptcha/docs/faq`).
For example:

.. code-block:: python

GR_CAPTCHA_SECRET_KEY = 'GoogleRecaptchaPrivateKey001'

Usage
-----

#. Now you can import and use the recaptcha field in your serializer.
For example:

.. code-block:: python

from rest_framework import serializers
from recaptcha.fields import ReCaptchaField

class ExampleSerializer(serializers.Serializer):
recaptcha = ReCaptchaField(write_only=True)
...

Unit Testing
~~~~~~~~~~~~

Django Rest reCAPTCHA uses an environment variable ``RECAPTCHA_TESTING`` which
helps tests. This environment variable should be set to ``"True"`` in your
testing environment and any value will be considered to be validated.

Example:

.. code-block:: python

import os
os.environ['RECAPTCHA_TESTING'] = 'True'

data = {'recaptcha': 'dummy value'}
response = client.post('/my/api/endpoint/', data)
assert response.status_code == 200

The code above may vary according to your testing suite.


Release files for django-rest-recaptcha 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-rest-recaptcha 1.0.2
File Size Uploaded
django-rest-recaptcha-1.0.2.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-rest-recaptcha 1.0.2
File Interpreter ABI Platform
django_rest_recaptcha-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size:7.5 kB

Release files / django-rest-recaptcha-1.0.2.tar.gz

Download URL django-rest-recaptcha-1.0.2.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f04928add4decdddaeffb1482a1d413e42cc8a7eb82c4af1ecded47538efde78
BLAKE2b-256 checksum
How to use checksums
e8c44e82793792acfd4e7f332bffbb7d59840b7d2890dea6c877fae82fe4fc84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release files / django_rest_recaptcha-1.0.2-py3-none-any.whl

Download URL django_rest_recaptcha-1.0.2-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3025dad5b720f51009f065eb6a957573e6bbe8c1d863d00ab795f4ef81f7694a
BLAKE2b-256 checksum
How to use checksums
392bd5636b960a1d11e400139a4a2d4158cc5c3f2a4b4ed9d082af65a9c7d322
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page