django框架管理员登录页面添加验证码功能

c 复制代码
B站视频-3分钟
https://www.bilibili.com/video/BV1TW421P7YD/

Django Simple Captcha 0.6.0 版本

c 复制代码
# 1官网
[Django Simple Captcha --- Django Simple Captcha 0.6.0 documentation (django-simple-captcha.readthedocs.io)](https://django-simple-captcha.readthedocs.io/en/latest/)
# 2使用方法
[Using django-simple-captcha --- Django Simple Captcha 0.6.0 documentation](https://django-simple-captcha.readthedocs.io/en/latest/usage.html)
# 3github项目地址
[GitHub - mbi/django-simple-captcha:Django Simple Captcha 是一个非常简单但高度可定制的 Django 应用程序,可以将验证码图像添加到任何 Django 表单中。](https://github.com/mbi/django-simple-captcha)

1:安装命令

c 复制代码
pip install  django-simple-captcha

2:在django项目中的settings.py中的INSTALLED_APPS中添加安装插件

c 复制代码
INSTALLED_APPS=[

'django内置插件开头'
'django内置插件结尾'
'captch'
]

3:安装完django-simple-captcha之后,才安装django-multi-captcha-admin 多合一版本

django-multi-captcha-admin 多合一版本

c 复制代码
# 1不同展示方式
[GitHub - a-roomana/django-multi-captcha-admin: easy add captcha to login page of django admin](https://github.com/a-roomana/django-multi-captcha-admin)
# 2线上视频
[向 Django 管理员添加验证码 - YouTube](https://www.youtube.com/watch?v=JYEwOSBcKvY&ab_channel=CloudWithDjango) 

1:安装命令

c 复制代码
pip install  django-multi-captcha-admin

2:在django项目中的settings.py中的INSTALLED_APPS中添加安装插件

c 复制代码
INSTALLED_APPS=[
'multi_captcha_admin',
'django内置插件开头'
'django内置插件结尾'
'captcha',
]

3:执行django的迁移

c 复制代码
python manage.py migrate

4:在urls.py中添加captcha路由

c 复制代码
from django.urls import path, include  
  
urlpatterns = [  
    path('admin/', admin.site.urls),  
    path('admin/login/', custom_login, name='custom_login'),  
    path('captcha/',include('captcha.urls')),  
]

5:在settings.py文件中添加 指定的验证码引擎

c 复制代码
MULTI_CAPTCHA_ADMIN={
	'engine':'simple-captcha',
}
MIDDLEWARE=[]

使用recaptcha2引擎

c 复制代码
MULTI_CAPTCHA_ADMIN={
	'engine':'recaptcha2',
}

请参考以下说明
[GitHub - kbytesys/django-recaptcha2: Django reCaptcha v2 field/widget](https://github.com/kbytesys/django-recaptcha2)

使用recaptcha引擎

c 复制代码
MULTI_CAPTCHA_ADMIN={
	'engine':'recaptcha',
}
请参考以下说明
[GitHub - django-recaptcha/django-recaptcha: Django reCAPTCHA form field/widget integration app.](https://github.com/django-recaptcha/django-recaptcha)
相关推荐
NineData4 小时前
NineData 迁移评估功能正式上线
数据库·dba
NineData10 小时前
数据库迁移总踩坑?用 NineData 迁移评估,提前识别所有兼容性风险
数据库·程序员·云计算
赵渝强老师12 小时前
【赵渝强老师】PostgreSQL中表的碎片
数据库·postgresql
全栈老石16 小时前
拆解低代码引擎核心:元数据驱动的"万能表"架构
数据库·低代码
倔强的石头_1 天前
kingbase备份与恢复实战(二)—— sys_dump库级逻辑备份与恢复(Windows详细步骤)
数据库
jiayou643 天前
KingbaseES 实战:深度解析数据库对象访问权限管理
数据库
李广坤4 天前
MySQL 大表字段变更实践(改名 + 改类型 + 改长度)
数据库
markfeng84 天前
Python+Django+H5+MySQL项目搭建
python·django
爱可生开源社区5 天前
2026 年,优秀的 DBA 需要具备哪些素质?
数据库·人工智能·dba
随逸1775 天前
《从零搭建NestJS项目》
数据库·typescript