Captcha图形验证
官网:https://django-simple-captcha.readthedocs.io/en/latest/index.html
安装:由于本人使用的是python2.7+django1.11,直接pip install django-simple-captcha会报错,所以需要指定版本,开始指定的和书中一致的0.5.1版本,但是最后运行的时候报错,最后使用0.5.5版本ok。
配置:
urls.py:
from django.conf.urls import url,include
from django.contrib import admin
from testdb import views
urlpatterns = [
url(r'^$',views.index),
url(r'^captcha/',include('captcha.urls')),
url(r'^alert/$',views.alert),
url(r'^admin/', admin.site.urls),
url(r'^(\d+)/(\w+)/$',views.index),
url(r'^list/$',views.listing),
url(r'^post/$',views.posting),
url(r'^contact/$',views.contact),
url(r'^post2db/$',views.post2db),
使用:
效果: