【问题标题】:Django - problem with django-simple-captchaDjango - django-simple-captcha 的问题
【发布时间】:2011-11-05 01:11:11
【问题描述】:

我有一个关于http://code.google.com/p/django-simple-captcha/ 项目的问题。我已经按照程序安装验证码,表单有效,但浏览器不加载图像。 怎么办?

我的模式:

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 admin
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}),
    )

【问题讨论】:

    标签: python django captcha


    【解决方案1】:

    在windows操作系统中

    1. pip install captcha

    2. 在已安装的应用中编辑 setting.py 以提及“验证码”

    3. 然后将 URL 添加到 urls.py,

      url(r'^captcha/', include('captcha.urls'))
      
    4. forms.py 写

      from captcha.fields import CaptchaField
      
      captcha = CaptchaField()
      
    5. 提交并更改验证码 .html 文件

       <button class='js-captcha-refresh'>Refresh Captcha</button><br><br>
       <input type="submit" class="btn btn-default" value="Submit" />
      

    【讨论】:

      【解决方案2】:

      确保您拥有 Captcha 应用程序的所有依赖项:cd 进入您的项目目录,然后运行:

      ./manage.py test captcha
      

      看看有没有报错。

      另外,请确保您已完成安装说明中的四个步骤:http://code.google.com/p/django-simple-captcha/#Installation

      【讨论】:

      • 我运行了那个测试命令,它检测到一个错误:ImportError: The _imagingft C module is not installed。我已经从这里link 安装了 PIL,它正在工作:)。谢谢!
      • 谢谢,有帮助!我也遇到了 _imagingfg 模块的问题,但 this thread 帮助了我。
      【解决方案3】:

      这不是很多信息,但我们开始了。如果你有谷歌浏览器,你可以用 ctrl-shift-i 打开浏览器检查器。转到资源选项卡,它应该有关于图像资源的错误。检查它试图加载哪个 url,看看为什么那个 url 上没有图像。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-18
        • 1970-01-01
        • 2013-09-29
        • 1970-01-01
        • 2014-01-18
        • 1970-01-01
        相关资源
        最近更新 更多