0

I'm trying to add a Django-Simple-Captcha image to my application's login screen.

This is what I have added at the top of my forms.py file:

from captcha.fields import CaptchaField

This is what I have added to the registration form:

captcha = CaptchaField(
    label="What does this say?",
    required=True,
)    

This is what I added to my site's url.py file: urlpatterns = patterns( '', url(r'^captcha/', include('captcha.urls')), )

I have also added "captcha" to my INSTALLED_APPS in settings.py

However, when I load the page, I see that the Captcha image is a broken link: http://predictstat.com/accounts/register/. The server shows this on the console:

[23/Dec/2013 16:30:47] "GET /captcha/image/56edd656ba57a2a3e71571373e1a59c564e3d592/ HTTP/1.1" 500 72336

However, there is no such directory "captcha" under the directory for my application. So where is it trying to look for this image? And why doesn't it exist?

Saqib Ali
  • 11,931
  • 41
  • 133
  • 272

1 Answers1

0

Use Chrome dev-tools or Firebug to view your server response. You are getting 500 status (server-error) because of this:

ImportError at /captcha/image/eeefc1bf784d38c4eecbcd61e2e3d42a28ea6792/
The _imagingft C module is not installed

This error occurs if your PIL module compiled without freetype library. Fix that and your error will disappear.

Dmitry Astrikov
  • 637
  • 1
  • 6
  • 16
  • Thanks. I just installed the libfreetype6-dev and then installed PIL. (See: https://gist.github.com/anonymous/8106990) But the result is the same: http://predictstat.com/accounts/register/ I am setting up Chrome dev-tools now. – Saqib Ali Dec 24 '13 at 00:25
  • Are you sure that your PIL is now support libfreetype? It should was in installation-log. Also, do you restart your webserver? – Dmitry Astrikov Dec 24 '13 at 01:06
  • Yes, I am re-starting the web server. I'm following the instructions in the last comment here: http://stackoverflow.com/questions/4011705/python-the-imagingft-c-module-is-not-installed Yet still it says "JPEG support not available" – Saqib Ali Dec 24 '13 at 01:15
  • Try to install PIL from source: wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz tar xvf Imaginig-1.1.7.tar.gz. And in setup.py point JPEG_ROOT variable to you libjpeg installation. – Dmitry Astrikov Dec 24 '13 at 01:22
  • Follow up, cleaner question here: http://stackoverflow.com/questions/20753607/while-upgrading-python-imaging-library-pil-it-tells-me-jpeg-support-not-avai – Saqib Ali Dec 24 '13 at 01:44