Easy-to-use django captcha or registration app with captcha?

后端 未结 3 1651
挽巷
挽巷 2020-12-23 12:10

I want to implement user registration using captcha in Django. The workflow of django-registration app is a great, but it doesn\'t have captcha.

What captcha would y

3条回答
  •  感动是毒
    2020-12-23 12:28

    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:

    1. download django-recaptcha (pip install django-recaptcha)

    2. install it on your project. That is, copy the "captcha" folder to your project, add "captcha" to INSTALLED_APPS and add your RECAPTCHA_PUBLIC_KEY and RECAPTCHA_PRIVATE_KEY keys to settings.py too (as described in the installation instructions)

    3. open registration/forms.py and add this field inside class RegistrationForm(forms.Form):

      captcha = ReCaptchaField()

      you will also have to import:

      from captcha.fields import ReCaptchaField

    And that's it. Less than a minute.

提交回复
热议问题