Hi django-heads, I found Martin Fowler's "Captcha for Django" here:
http://django.agami.at/media/captcha/. This is by far the easiest to
use captcha system for django that I've found on the 'net, but I
found it was outdated (not working w/ 1.0 or 1.1).
If anyone is interested, I've created a patch to get it to work with
the latest version of django:
--- cut below here ---
diff -Nur captcha/__init__.py captcha-new/__init__.py
--- captcha/__init__.py 2007-06-14 12:53:55.000000000 -0500
+++ captcha-new/__init__.py 2009-03-14 10:51:18.000000000 -0500
@@ -13,11 +13,12 @@
import tempfile
import datetime
from PIL import Image, ImageColor, ImageFont, ImageDraw
-from django.newforms import *
-from django.newforms.fields import CharField
+from django.forms import Widget, Field
+from django.forms.fields import CharField
from django.conf import settings
from django.utils.translation import gettext
from django.utils.datastructures import MultiValueDict
+from django.utils.safestring import mark_safe
def clean_old_entries(captchas_dir, max_age=1200):
"""maintainance function for deleting all expired captchas
@@ -89,12 +90,14 @@
img = Image.new('RGB',self.csettings['imagesize'],
self.csettings['bgcolor'])
for dummy in range(self.csettings['iterations']):
img = self.generate_image(img)
- return u'''<input type="hidden" name="%(name)s"
value="captcha.%(hiddentext)s"
+ html = u'''<input type="hidden" name="%(name)s"
value="captcha.%(hiddentext)s"
/><img src="%(imageurl)s" alt="" /><br
/><input type="text" name="%(name)s" id="id_%(name)s" />''' %
{'name':name,
'hiddentext': self.hiddentext,
'imageurl': self.imageurl }
+ return mark_safe(html)
+
def generate_image(self, bgimage):
""" create a image file.
the filename looks like TMPNAME.HASH.EXT
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---