Django Simple CaptchaAboutDjango Simple Captcha is an extremely simple, yet highly customizable Django application to add captcha images to any Django form.
UsageSample view:
from django
... [More]
import forms
from captcha.fields import CaptchaField
from django.shortcuts import render_to_response
class CaptchaTestForm(forms.Form):
myfield = AnyOtherField()
captcha = CaptchaField()
"""
# or, as a ModelForm:
class CaptchaTestModelForm(forms.ModelForm):
captcha = CaptchaField()
class Meta:
model = MyModel
"""
def home(request):
if request.POST:
form = CaptchaTestForm(request.POST)
# Validate the form: the captcha field will automatically
# check the input
if form.is_valid():
human = True
else:
form = CaptchaTestForm()
return render_to_response('base.html',locals())
FeaturesVery simple to setup and deploy, yet very configurable Can use custom challenges (e.g. random chars, simple maths, dictionary word, ...) Custom generators, noise and filter functions alter the look of the generated image Supports text-to-speech audio output of the challenge text, for improved accessibility RequirementsDjango 1.0+ A fairly recent version of the Python Imaging Library (PIL) compiled with FreeType support Flite is required for text-to-speech (audio) output, but not mandatory InstallationDownload the 'captcha' application and put it anywhere in your Python path (or using setuptools: sudo easy_install django-simple-captcha) Add 'captcha' to the INSTALLED_APPS in your settings.py Run manage.py syncdb to create the required database tables Add an entry to your urls.py: urlpatterns += patterns('',
url(r'^captcha/', include('captcha.urls')),
)ConfigurationSee CaptchaConfiguration for details on available configuration settings.
GeneratorsSee CaptchaGenerators for a list of available challenge generator functions.
.gadget-title {
margin-bottom: 2px;
}
function resizeIframeHandler(opt_height) {
var elem = document.getElementById(this.f);
if (!elem) return;
if (!opt_height) {
elem.style.height = undefined;
}
else {
opt_height = Math.max(10, opt_height);
elem.style.height = opt_height + 'px';
}
}
gadgets.rpc.register("resize_iframe", resizeIframeHandler);
gadgets.rpc.register('set_title', function(title) {
var elem = document.getElementById(this.f + '_title');
if (elem) {
elem.innerHTML = gadgets.util.escape(title);
}
}); [Less]