赞
踩
pip install django-simple-captcha
pip install Pillow
# MxOnline/settings.py
INSTALLED_APPS = [
# 图片登陆验证
'captcha',
]
py manage.py migrate
根目录下的urls.py文件中增加captcha对应的网址:
# MxOnline/urls.py
urlpatterns = [
path('register', RegisterView.as_view(), name='register'),
# 这是生成验证码的图片
path('captcha/',include('captcha.urls')),
]
# users/forms.py
from captcha.fields import CaptchaField
class RegisterForm(EmailCheckMixin):
"""注册表单"""
# 为生成的验证码图片,以及输入框
captcha = CaptchaField(error_messages={'invalid': '验证码错误'})
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。