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)
相关推荐
心丑姑娘3 分钟前
使用ClickHouse时的劣质SQL样例
数据库·sql·clickhouse
什么都不会的Tristan14 分钟前
redis篇
数据库·redis·缓存
only°夏至besos19 分钟前
MySQL 运维实战:常见问题排查与解决方案
运维·数据库·mysql
液态不合群20 分钟前
并发,并行与异步
数据库
Dxy123931021626 分钟前
MySQL如何批量更新数据:高效方法与最佳实践
数据库·mysql
曲幽28 分钟前
FastAPI数据库实战:从SQLAlchemy原理到高效连接管理,告别性能瓶颈
python·sqlite·flask·fastapi·web·sqlalchemy·db
dishugj36 分钟前
【Oracle】 Flashback(闪回)技术实操指南
数据库·oracle·flashback
白山云北诗39 分钟前
中小企业如何做好企业官网的网络安全
网络·数据库·web安全·ddos·cc·企业网络安全
lkbhua莱克瓦241 小时前
进阶-存储对象2-存储过程上
java·开发语言·数据库·sql·mysql
码农胖虎-java1 小时前
【AI】向量数据库选型实战:pgvector vs Milvus vs Qdrant
数据库·milvus·pg