赞
踩
官方文档:https://django-simple-captcha.readthedocs.io/en/latest/usage.html
官方demo
1、forms.py中定义
- from django import forms
- from captcha.fields import CaptchaField
-
- class CaptchaTestForm(forms.Form):
- myfield = AnyOtherField()
- captcha = CaptchaField()
2、views.py中引用
- def some_view(request):
- if request.POST:
- form = CaptchaTestForm(request.POST)
-
- # Validate the form: the captcha field will automatically
- # check the input
- if form.is_valid():
- human = True
- else:
- form = CaptchaTestForm()
-
- return render_to_response('template.html',locals())
'运行
输入’23‘,执行中的断点信息
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。