Is there any solutions to use captcha with django-allauth? I want to use captcha on registration form for standard email+password registrations.
I too needed to do this with django-allauth and found that implementing the django-recaptcha package to be relatively simple.
Sign up for a recaptcha account.
Plug your settings in
# settings.py
RECAPTCHA_PUBLIC_KEY = 'xyz'
RECAPTCHA_PRIVATE_KEY = 'xyz'
RECAPTCHA_USE_SSL = True # Defaults to False
After installing django-recaptcha, I followed someguidelines for customizing the SignupForm.
from django import forms
from captcha.fields import ReCaptchaField
class AllAuthSignupForm(forms.Form):
captcha = ReCaptchaField()
def save(self, request, user):
user = super(AllAuthSignupForm, self).save(request)
return user
You also need to tell allauth to inherit from this form in settings.py
ACCOUNT_SIGNUP_FORM_CLASS = 'myapp.forms.AllAuthSignupForm'
{{ form.captcha }} and {{ form.captcha.errors }} should be available on the signup template context at this point.
That was it! Seems like all the validation logic is tucked into the ReCaptchaField.
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