A Django package that is essentially a fork of Vitor Freitas' simple-recaptcha repo (licensed under MIT License). Contains a decorator for use with reCAPTCHA v2. Thanks Vitor!
This package has no tests yet—and therefore, is not production-ready.
Also, reCAPTCHA v3 and invisible reCAPTCHA is not supported yet.
- Install the app using:
pip install git+https://github.com/armandtvz/django-simple-recaptcha.git
- Add "recaptcha" to your INSTALLED_APPS setting:
INSTALLED_APPS = [
...
'recaptcha',
]
- Add the following to the MIDDLEWARE setting:
MIDDLEWARE = [
'...',
'recaptcha.middleware.ReCaptchaCredentialMiddleware',
]
- Add the following to your settings.py file (remember to always protect secret keys appropriately):
# These settings will only be used in production.
GOOGLE_RECAPTCHA_SITE_KEY = <recaptcha_site_key>
GOOGLE_RECAPTCHA_SECRET_KEY = <recaptcha_secret_key>
- Add the required JS to the template:
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
- Add the reCAPTCHA checkbox to the template:
<div class="g-recaptcha" data-sitekey="{{ request.recaptcha_site_key }}"></div>
<!-- Or use the checkbox template -->
{% include "recaptcha/checkbox.html" %}
This project is licensed under the GPL-3.0 public license. See LICENSE.