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)
相关推荐
麦兜*1 分钟前
MongoDB 在物联网(IoT)中的应用:海量时序数据处理方案
java·数据库·spring boot·物联网·mongodb·spring
-Xie-36 分钟前
Mysql杂志(十六)——缓存池
数据库·mysql·缓存
七夜zippoe39 分钟前
缓存与数据库一致性实战手册:从故障修复到架构演进
数据库·缓存·架构
一个天蝎座 白勺 程序猿1 小时前
Apache IoTDB(5):深度解析时序数据库 IoTDB 在 AINode 模式单机和集群的部署与实践
数据库·apache·时序数据库·iotdb·ainode
QQ3596773452 小时前
ArcGIS Pro实现基于 Excel 表格批量创建标准地理数据库(GDB)——高效数据库建库解决方案
数据库·arcgis·excel
学编程的小程2 小时前
突破局域网限制:MongoDB远程管理新体验
数据库·mongodb
百锦再2 小时前
[特殊字符] Python在CentOS系统执行深度指南
开发语言·python·plotly·django·centos·virtualenv·pygame
波波烤鸭2 小时前
Redis 高可用实战源码解析(Sentinel + Cluster 整合应用)
数据库·redis·sentinel
l1t6 小时前
利用DeepSeek实现服务器客户端模式的DuckDB原型
服务器·c语言·数据库·人工智能·postgresql·协议·duckdb