Good night, welcome back again in Python Learning, this time i wanna share simply tutorial how to Install Django Recaptcha from Google reCAPTCHA.
There is using Django reCAPTCHA, for more you can checkout at this repository https://github.com/praekelt/django-recaptcha
- Makesure you already has the form before setup Django reCAPTCHA.
- Installing django from pip:
$ pip install django-recaptcha
or directly from branch. - Add
captcha
to yourINSTALLED_APPS
onsettings.py
INSTALLED_APPS = (
....,
'captcha',
)
- Put some keys from Google reCAPTCHA, for example like this in you
settings.py
RECAPTCHA_USE_SSL = True
RECAPTCHA_PUBLIC_KEY = '76wtgdfsjhsydt7r5FFGFhgsdfytd656sad75fgh'
RECAPTCHA_PRIVATE_KEY = '98dfg6df7g56df6gdfgdfg65JHJH656565GFGFGs'
5. Usage Django reCAPTCHA for example like this in your forms.py
from django import forms
from member.models import Member
from captcha.fields import ReCaptchaField
class RegisterForm(forms.ModelForm):
captcha = ReCaptchaField(attrs={'theme' : 'clean'})
class Meta:
model = Member
fields = ['username', 'email', 'password']
Thereis basiclly how to install and usage your Django reCAPTCHA, and will automatically manage error response or success response. Simply right?
for more usage, you can checkout on this repository: https://github.com/praekelt/django-recaptcha