一. 图片验证码
- 使用插件 django-simple-captcha
- 开源地址: https://github.com/mbi/django-simple-captcha
- 官方文档: http://django-simple-captcha.readthedocs.io/en/latest/usage.html#installation
- 安装:
Install django-simple-captcha
或者
pip install django-simple-captcha==0.6.4
- 使用步骤
1 添加app
# settings.py
INSTALLED_APPS = [
...
'captcha',
]
2 建立form表单类
# forms.py
#一般将一些表单类写到同一个py文件里
from captcha.fields import CaptchaField
class RegisterForm(forms.Form):
# 邮箱
email = forms.EmailField(required=True, )
# 密码验证
password = forms.CharField(required=True)
#invalid 表示出错时候的显示信息.
captcha = Captch