Django library for friendly captcha
Project description
Django library for Friendly Capture (https://friendlycaptcha.com).
Installation
Latest version:
pip install -e git+git://github.com/christianwgd/django-friendly-captcha.git#egg=django-friendly-captcha
Stable version:
pip install django-friendly-captcha
Documentation
Usage
Add ‘friendly_captcha’ to your INSTALLED_APPS.
INSTALLED_APPS = [
...
'friendly_captcha',
]
Add the captcha field to your form:
from friendly_captcha.fields import FrcCaptchaField
class ContactForm(forms.ModelForm):
class Meta:
model = ContactMessage
fields = (
'name', 'email', 'subject', 'text'
)
captcha = FrcCaptchaField()
Add the script tags from friendly capture to your forms template (see https://docs.friendlycaptcha.com/#/installation)
<script type="module" src="https://unpkg.com/friendly-challenge@0.8.1/widget.module.min.js" async defer></script>
<script nomodule src="https://unpkg.com/friendly-challenge@0.8.1/widget.min.js" async defer></script>
Configuration
Register to Friendly Captcha at https://friendlycaptcha.com/signup to get your sitekey and captcha secret.
FRC_CAPTCHA_SECRET = '<yourCaptchaSecret'
FRC_CAPTCHA_SITE_KEY = '<yourCaptchaSiteKey>'
FRC_CAPTCHA_VERIFICATION_URL = 'https://friendlycaptcha.com/api/v1/siteverify'
In default the form will fail with an error (‘Captcha test failed’). You can change this behaviour by setting FRC_CAPTCHA_FAIL_SILENT to True.
FRC_CAPTCHA_FAIL_SILENT = False
When setting FAIL_SILENT to True it’s up to you to handle captcha verification:
# in your form view
def form_valid(self, form):
captcha_verified = form.cleaned_data['captcha']
if captcha_verified:
# send mail or whatever ...
else:
# capture verification failed, do nothing ...
Logging
If you want to log the results of the captcha verifications you can add a logger to your logging configuration:
'django.friendly_captcha': {
'handlers': ['default'],
'level': 'INFO',
}
Releases
django_friendly_captcha 0.1.0 (March 2021): Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-friendly-captcha-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bebb4cc39d8becc15f96379af3b957e869077e0c1772725f20de62032050b0f6 |
|
MD5 | 59bd6e700815d6c61e5eed76b25f3569 |
|
BLAKE2b-256 | 4387ed03f00300a64bba5c92bf41509d2e3e0fae63d6789e81dd0c931a7b96fb |
Hashes for django_friendly_captcha-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98ed3c15c12f34189dc529d992facab78e8be60dab31749c3f0bcecb7da9c664 |
|
MD5 | e63bc8fe2d6bd6cb07c61a75a3903a43 |
|
BLAKE2b-256 | 8387bcbeb1055823f73031ebd820644609c5ae7367c6520e55fd9547b855e952 |