django框架的简单而友好的验证码模块。
django-color-captcha的Python项目详细描述
快速启动
将color_captcha添加到已安装的应用程序中
INSTALLED_APPS = [ ... 'color_captcha', ... ]
运行collectstaticmanage命令
> python manage.py collectstatic
将color_captcha.css文件添加到模板中
<link rel="stylesheet" href="{{ STATIC_URL }}color_captcha/css/color_captcha.css" type="text/css"/>
将ColorCaptchaField添加到表单中
from django import forms from color_captcha.fields import ColorCaptchaField class MyForm(forms.Form) ... captcha = ColorCaptchaField(label='Choose a color') ...
配置
请随意使用以下选项配置您的验证码。
验证码颜色
Default:
[ ('white', 'white'), ('blue', 'blue'), ('red', 'red'), ]An iterable of two-string-value tuples. The first value in tuple is a HEX color code (e.g. ^{tt5}$) or css color constant (e.g. ^{tt6}$). The second value is a color name for user who has to solve the captcha.
验证码错误消息
Default:
{ 'wrong': 'Wrong answer', 'required': 'This field is required', 'internal': 'Internal error', }A dictionary with error messages for captcha field. You can override any of them.