搭建网站很经常要用到验证码,django中就有这样的中间件django-simple-captha

githup地址https://github.com/mbi/django-simple-captcha.git

下载完之后,切换到下载的目录下pip install django-simple-captcha安装

如何使用

一在setting中install_app中添加captcha

二运行python manage.py makemigrations captcha,python manage.py migrate captcha

三在urls中添加

url(r'^captcha/', include('captcha.urls')),

在form中添加一个CaptchaField

from django import forms
from captcha.fields import CaptchaField class CaptchaTestForm(forms.Form):
myfield = AnyOtherField()
captcha = CaptchaField()

到时候验证form的时候如果验证码不正确会提示不合法

四在html添加captcha

<form action='.' method='POST'>
{{ form.captcha }}
<input type="submit" />
<button class='js-captcha-refresh'></button>
</form>

注意点击更改验证码要自己写js实现哦

最新文章

  1. [Asp.net 5] ApplicationBuilder详解
  2. ArcGIS 10.5新功能预览
  3. interactivePopGestureRecognizer
  4. python发邮件实现Redis通知功能
  5. 除了白名单外的IP每秒最多处理 8 个请求 limit_conn_zone
  6. 求二叉树的深度和宽度[Java]
  7. 武汉科技大学ACM:1009: 华科版C语言程序设计教程(第二版)习题5.12
  8. 在SSH整合框架中经常会用到Service层,请问大家这个Service层有什么具体的作用,可不可以不用这个Service层呢?
  9. 标签(Tag)的各种设计方案
  10. hdu1198--并查集
  11. Python开发【第十六篇】:AJAX全套(转)
  12. 使用Mongo进行分页
  13. 源码分析八( hashmap工作原理)
  14. web socket
  15. js条件判断if-else和switch、循环for和while
  16. library之目录
  17. [python]python安装包错误
  18. 4gcc编译器
  19. anaconda安装出现failed to create anacoda menue
  20. Bat 获取本地代码的Svn Revision并保存到变量

热门文章

  1. 湘潭邀请赛 2018 D Circular Coloring
  2. 如何用js让表格的行也能拖动
  3. spring in action 学习笔记十:用@PropertySource避免注入外部属性的值硬代码化
  4. elementui 日期选择器设置当前默认日期(picker-options),以及当前日期以后的无法选择(default-value)
  5. .net使用memcached
  6. php5.3+ 安装(mysqlnd )
  7. nginx 根据url访问次数限制
  8. Zabbix监控服务器异常IP登录
  9. 兼容ie7到ie11,edge,chrome,firefox的ajax发送接收post数据代码
  10. Python基础-迭代器&amp;生成器&amp;装饰器