3

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
  • I'm currently working in the same issue. Fun fact: if you use html inspector (such as Firebug or Chrome tools) and change the image url to `/captcha/static/image/.../` it is shown. Now I'm trying to figure out how to transform this url or make some kind of collectstatic. – Rômulo Collopy Feb 11 '15 at 12:41

4 Answers4

4

On closer inspection, I found the issue was this:

Exception Value: The _imagingft C module is not installed.

Details how to solve this issue can be found here: Python: The _imagingft C module is not installed

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

There is no need to create any captcha directories.

The problem is that you did not update your urls.py as mensioned in the documentation:

urlpatterns += patterns('',
    url(r'^captcha/', include('captcha.urls')),
)

Another problem could be that you did not run syncdb:

./manage.py syncdb
./manage.py migrate   # If you use migrations
niekas
  • 8,187
  • 7
  • 40
  • 58
  • Sorry, I failed to mention it, I did update my urls.py: urlpatterns += patterns('', url(r'^captcha/', include('captcha.urls')), ) – Saqib Ali Dec 23 '13 at 22:51
  • You get error when accessing ``/catcha/img/`` url, try to find out what kind of error it is. Did you run ``syncdb`` and ran migrations (if you use them)? – niekas Dec 23 '13 at 23:10
  • Yes. Synchdb has been run. There is no error accessing captcha/image/. The image simply doesn't show up. But I don't think that it really expects that directory to be there anyway. (In another working django-captcha application I have, it isn't there) So I'm a bit confused. – Saqib Ali Dec 23 '13 at 23:13
1

The same was happening in my application and I manage to make a very strange workaround (XGH alert) usising two slashes in django-simple-captcha 0.4.4

urlpatterns += patterns('',
    url(r'^captcha//', include('captcha.urls')),
)
Rômulo Collopy
  • 944
  • 9
  • 13
0

I think it may has something with the conflict of globally and virtureenv environment,may be there is another app which contains the name captcha.

dkjf
  • 59
  • 8