因为我的项目里面刚才删除了App,所以现在手动建立一个新的App
1.python manage.py startapp App
2.修改setting配置文件
3.增加路由
可以把day06下的url拷贝过来
4.修改路由
5.安装第三方应用
6.设置验证码
抄代码也是累啊
# CAPTCH 验证码设置
CAPTCHA_IMAGE_SIZE = (80, 45) # 设置captcha图片大小
CAPTCHA_LENGTH = 4 # 设置字符个数
CAPTCHA_TIMEOUT = 1 # 超时(minutes)
# 输出格式: 输入框 验证码图片 隐藏区域
CAPTCHA_OUTPUT_FORMAT = '%(text_field)s %(image)s %(hidden_field)s'
CAPTCHA_NOISE_FUNCTIONS = ('captcha.helpers.noise_null',
'captcha.helpers.noise_arcs', # 线
'captcha.helpers.noise_dots', # 点
)
# 随机字符验证码
CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.random_char_challenge'
数学库:
CAPTCHA_CHALLENGE_FUNCT = ‘captcha.helpers.math_challenge’
7.配置路由
path('captcha/', include("captcha.urls")),
8.需要做数据迁移
python manage.py migrate
我们的验证码将在这个表里面生成