I have an issue about http://code.google.com/p/django-simple-captcha/ project. I've follow the procedure to install captcha, the form works but the browser don't load the image. What to do?
My patterns:
from django.conf.urls.defaults import patterns, include, url
from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import a开发者_运维问答dmin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'main.views.main', name="main_page"),
url(r'^registration$', 'main.views.registration', name="registration"),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
# Captcha
url(r'^captcha/', include('captcha.urls')),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^files/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
)
Make sure you have all the dependencies for the Captcha app: cd into your project directory, then run:
./manage.py test captcha
See if it reports any errors.
Also, make sure you've completed the four steps in the installation instructions: http://code.google.com/p/django-simple-captcha/#Installation
it's not very much info to go by, but here we go. if you have google chrome you can do ctrl-shift-i to open the browser inspector. go to the resources tab, it should have an error about an image resource. check which url it tries to load and see why there isn't an image at that url.
in windows operating System
pip install captcha
edit setting.py in installed app to mention 'captcha'
after that add URL to urls.py,
url(r'^captcha/', include('captcha.urls'))
forms.py write
from captcha.fields import CaptchaField captcha = CaptchaField()
Submit and change the captcha .html file
<button class='js-captcha-refresh'>Refresh Captcha</button><br><br> <input type="submit" class="btn btn-default" value="Submit" />
精彩评论