Lite captcha for django projects. This package don't use database for store captcha.
Detailed documentation is in the "docs" directory.
- Install package
pip install lite_captcha
- Add "lite_captcha" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
# ...
'lite_captcha',
]
- Configure
MEDIA_URL
andMEDIA_ROOT
: - Use form field in your forms:
from django import forms
from lite_captcha.forms import LiteCaptchaField
class ContactForm(forms.Form):
email = forms.EmailField(required=True)
message = forms.CharField(required=True, widget=Textarea)
captcha = LiteCaptchaField(required=True)
- Set session instance in views
# ... in some views
if request.method == 'POST':
form = ContactForm(request.POST)
form.fields['captcha'].session = request.session
if form.is_valid():
return HttpResponseRedirect('/')
else:
form = ContactForm()
form.fields['captcha'].session = request.session
# ...
- Override templates or use default.
- Optional, change default django session backend for more performance.