django-simple-captcha 验证码插件
来源:互联网 发布:js旋转图片animate 编辑:程序博客网 时间:2024/05/17 01:17
官方文档:http://django-simple-captcha.readthedocs.io/en/latest/usage.html#installation
github:https://github.com/mbi/django-simple-captcha
安装部署
版本:django 1.9
1
pip
install
django-simple-captcha==0.4.6
- settings.py配置,加入captcha
1
2
3
4
5
6
7
8
9
INSTALLED_APPS = [
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'captcha'
,
]
- urls.py配置
加入url(r'^captcha/', include('captcha.urls')),
1
2
3
4
5
6
7
from django.conf.urls
import
url, include
from django.contrib
import
admin
urlpatterns = [
url(r
'^admin/'
, admin.site.urls),
url(r
'^captcha/'
, include(
'captcha.urls'
)),
]
- 数据库同步
1
2
makemigrations
migrate
应用场景
- form定义
app下自定义froms.py文件,创建一个注册form
1
2
3
4
5
6
7
from django
import
forms
from captcha.fields
import
CaptchaField
class RegisterForm(forms.Form):
email = forms.EmailField(required=True)
password = forms.CharField(required=True, min_length=5)
captcha = CaptchaField(error_messages={
"invalid"
: u
"验证码错误"
})
- views.py代码
1
2
3
4
5
6
7
from django.views.generic.base
import
View
class RegisterView(View):
def get(self, request):
register_form = RegisterForm()
return
render(request,
"register.html"
, {
"register_form"
: register_form})
- html页面引用
1
{{ register_form.captcha }}
阅读全文
0 0
- django-simple-captcha 验证码插件
- 【Django插件使用】Django Simple Captcha登陆验证码
- django 验证码(django-simple-captcha)
- django-simple-captcha 验证码插件 和自己实现验证码的
- django-simple-captcha==0.4.6 验证码插件使用方法
- django中验证码——django-simple-captcha
- django - 验证码 django-simple-captcha 使用简介
- Django 验证码的使用 -django-simple-captcha使用方法
- django验证码框架(django-simple-captcha)
- django-simple-captcha 使用 以及添加动态ajax刷新验证
- django-simple-captcha refresh & validation
- django-simple-captcha & jquery validate
- CentOS-6.4安装django-simple-captcha小记
- 用Rails Captcha插件,轻松实现验证码
- 验证码(CAPTCHA)
- captcha验证码入门
- 验证码 Captcha
- Laravel5 验证码Captcha 扩展
- 计算机中丢失boost_system-vc100-mt-1.59.dll
- 访问不了Tomcat主页解决方法
- Linux下安装配置MySQL服务器
- 超强、超详细Redis数据库入门教程
- jQuery插件开发(一)基础介绍
- django-simple-captcha 验证码插件
- 定制 eclipse 工具栏 mars 版本
- GC 调优(工具篇)
- linux简单的自用的日志记录函数
- fedora 安装与系统升级
- Linux 配置tomcat 虚拟目录
- github上搭建项目
- mysql 之 CONCAT() 和 GROUP_CONCAT()
- 我在软通大学的实训总结报告