django-simpleui-captcha 是一个 django 后台管理登录验证码插件
pip install django-simpleui-captcha
- Django
- django-simple-captcha
INSTALLED_APPS = [
"simpleui_captcha",
"simpleui",
...
]
path('simpleui_captcha/', include('simpleui_captcha.urls')),
# urls.py
from simpleui_captcha.views import LoginWithCaptcha
urlpatterns = [
path('admin/login/', LoginWithCaptcha.as_view(), name='admin_login'),
path('admin/', admin.site.urls),
...
]
# settings.py 默认值
SIMPLEUI_CAPTCHA = {
'FAILED_LOGIN_COUNT_NAME': 'failed_login_count', # session 的键名
'MAX_FAILED_LOGIN_COUNT': 3, # 不需要输验证码的最大失败次数
}