21đź‘Ť
django-registration is pretty extendable. One way to extend it is to provide a custom registration form. I’d recommend to use reCaptcha, e.g. with the widget and form field from here (archived). Then it is as simple as writing a custom form class and registration backend (which is simpler than it sounds):
from registration.backends.default import DefaultBackend
from registration.forms import RegistrationForm
class RecaptchaRegistrationForm(RegistrationForm)
recaptcha = ReCaptchaField(label="I'm a human")
class RecaptchaRegistrationBackend(DefaultBackend):
def get_form_class(self, request):
return RecaptchaRegistrationForm
The last step is to tell django-registration to use your backend. That step is described in the docs (I couldn’t find a HTML version of the docs, sorry)
21đź‘Ť
I’ve just had this problem, but the solution is dead simple.
I’m using django-registration, and I want a reCAPTCHA field for user registration. In just 1 minute:
-
download django-recaptcha (
pip install django-recaptcha
) -
install it on your project. That is, copy the “captcha” folder to your project, add “captcha” to
INSTALLED_APPS
and add yourRECAPTCHA_PUBLIC_KEY
andRECAPTCHA_PRIVATE_KEY
keys to settings.py too (as described in the installation instructions) -
open
registration/forms.py
and add this field insideclass RegistrationForm(forms.Form):
captcha = ReCaptchaField()
you will also have to import:
from captcha.fields import ReCaptchaField
And that’s it. Less than a minute.
- [Django]-AttributeError: 'ManyRelatedManager' object has no attribute 'add'? I do like in django website but got this error
- [Django]-Uwsgi installation error in windows 7
- [Django]-Django Push HTTP Response to users
16đź‘Ť
For those like me arriving late to the thread, there are a bunch of solutions out there now, which are pretty easy to install:
- http://code.google.com/p/django-simple-captcha/
- http://code.google.com/p/django-captcha/
- https://github.com/inueni/django-captcha-field
- https://github.com/justquick/django-math-captcha
- https://github.com/marconi/django-mollom which uses the third-party Mollom service (which provides captcha and spam-filtering services).
I’ve successfully setup Django Mollom and Django Simple Captcha, and the hardest part was yak shaving around installing PIL on my Mac. Implementing the code was as straightforward as the docs for each would suggest.
- [Django]-Django signals vs. overriding save method
- [Django]-How to check if something exists in a postgresql database using django?
- [Django]-Django templates: Best practice for translating text block with HTML in it