memclutter / django-lite-captcha

Lite captcha for django projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django Lite Captcha

Language Python Hex.pm

Lite captcha for django projects. This package don't use database for store captcha.

Detailed documentation is in the "docs" directory.

Quick start

  1. Install package
pip install lite_captcha
  1. Add "lite_captcha" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
    # ...
    'lite_captcha',
]
  1. Configure MEDIA_URL and MEDIA_ROOT:
  2. 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)
  1. 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

    # ...
  1. Override templates or use default.
  2. Optional, change default django session backend for more performance.

About

Lite captcha for django projects

License:Apache License 2.0


Languages

Language:Python 90.3%Language:HTML 9.7%