I would like to add captcha on my django registration form using Django Simple Captcha found here: http://code.google.com/p/django-simple-captcha/
This works great if you create a new form but I'm using the django.contrib.auth.forms the one that comes with django. Any idea how I might be able to implement captcha with the existing django auth views? Thank you!
You could simply subclass the django.contrib.auth.forms forms and add a CaptchaField, like this:
from django.contrib.auth.forms import UserCreationForm
from captcha.fields import CaptchaField
class CaptchaUserCreationForm(UserCreationForm):
captcha = CaptchaField()
and use the new Form in your view as usual:
if request.POST:
form = CaptchaUserCreationForm(request.POST)
if form.is_valid():
return HttpResponseRedirect('/?ok')
else:
form = CaptchaUserCreationForm()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With