Integrate reCAPTCHA to a Django Form Model

I needed an implementation to prevent spamming programs and bots from using the contact form. I have decided to used reCAPTCHA since it also helps to digitize scanned text materials. A google search on 'django recaptcha' led me to marco rucci's blogsite.

I followed the instructions and created the source files based on the article. I managed to get the reCAPTCHA rendered and running, but I had an issue with its out of the box solution. The default red CSS theme uses a table class style that does not go well with my site's css layout. Fortunately, the reCAPTCHA API allows one to customize the way the captcha components are displayed. I hacked the downloaded python recaptcha-clientto include another flag to use custom theme in its displayhtml function. I had also updated marco rucci's widgets.py file to include the new use_custom_theme variable flag.

Note: The project settings file needs to include a new variable called RECAPTCHA_USE_CUSTOM_THEME (True to use custom theme or False to use the default red theme).

Here are the attached code changes and please leave some comments if you have any.

Attachments





Meta

Published: May 19, 2011

Author: James Ng

Comments: goto comment section

Word Count: 183

Next: The middle way and be like water

Previous: Knowing the different body types and eating naturally

Bookmark and Share

Tags

django python

Article Links

  1. contact form
  2. Integrating reCAPTCHA with Django - Marco Fucci
  3. Customizing the Look and Feel of reCAPTCHA - reCAPTCHA — ...
  4. recaptcha-client 1.0.6 : Python Package Index


Comments powered by Disqus