Captcha example

67 views
Skip to first unread message

Mike

unread,
Feb 20, 2007, 10:19:39 AM2/20/07
to Django users
Hello,

Can anyone puke up a simple example of using captcha with Django
forms? [I've already RTFM&N.]

I installed the app code from http://code.google.com/p/django-captcha/
and noticed the test but don't see how it works with templates and
extraspecially newforms (needs to be a tag library?).

If there's a better or simpler option for implementing captcha I'd be
especially interested in that.

Thank you!

Joseph Heck

unread,
Feb 20, 2007, 1:24:49 PM2/20/07
to django...@googlegroups.com
I used a very slight variation off that same code base - so let me take a stab at explaining what the general idea is behind how captcha was implemented -

In the view where you're going to display a captcha, generate first a "captcha" that just goes into the database - a combination of a UUID, the text of the captcha, and perhaps a timestamp that limits the time the captcha is valid. I use a limited alphabet to generate a random string. Pass the UUID of the captcha into the view

Have a specific view method that takes the UUID, generates the image, and returns it.

When the form gets it's data back, make sure you pass through the UUID of that requested captcha (I toss it into a <hidden> field). DO a check between the UUID handed back and the text the user entered - if it's good, nuke the Captcha request in the database and let them move on.

Does that help at all?

-joe

Mike

unread,
Feb 21, 2007, 8:26:28 AM2/21/07
to Django users
Hi Joe,

Thanks for taking the time to respond--that makes sense to me.

I had to go all the way to Poland but finally found a working code
example (Dziękuję!). Here's the link in case it's helpful for someone
else:

http://www.rkblog.rk.edu.pl/w/p/django-and-captcha-images/


Reply all
Reply to author
Forward
0 new messages