Python-reCaptcha is a pythonic and well-documented reCAPTCHA client that supports all the features of the remote API to generate and verify CAPTCHA challenges. To add to your Django project, you need captcha public, private keys are required.
How to integrate reCaptcha with Django?
Following gives you a brief idea of how to integrate reCaptcha to Django application
in settings.py
CAPTCHA_PUBLIC = 'XXXXXXXXXXXXXXXXXX'
CAPTCHA_PRIVATE = 'XXXXXXXXXXXXXXXXXX'
in views.py
recaptcha = captcha.displayhtml(CAPTCHA_PUBLIC)
#displayhtml() gives the captcha object to be displayed on html
return render_to_response('demo.html','recaptcha':recaptcha)
in demo.html
<form action="/" method="post">
{{recaptcha|safe}}
<button class="submit" type="submit">Submit</button>
</form>
in views.py
capresponse = captcha.submit( request.POST.get('recaptcha_challenge_field'),
request.POST.get('recaptcha_response_field'),
CAPTCHA_PRIVATE,
request.META.get('REMOTE_ADDR'))
'''checks if the catpcha is valid or not(challenge field and response fields are equal or not '''
if capresponse.is_valid:
do_some_work()
else:
return HttpResponse('wrong captcha text')
Micropyramid is a software development and cloud consulting partner for enterprise businesses across the world. We work on python, Django, Salesforce, Angular, Reactjs, React Native, MySQL, PostgreSQL, Docker, Linux, Ansible, git, amazon web services. We are Amazon and salesforce consulting partner with 5 years of cloud architect experience. We develop e-commerce, retail, banking, machine learning, CMS, CRM web and mobile applications.
Django-CRM :Customer relationship management based on Django
Django-blog-it : django blog with complete customization and ready to use with one click installer Edit
Django-webpacker : A django compressor tool
Django-MFA : Multi Factor Authentication
Docker-box : Web Interface to manage full blown docker containers and images
More...