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 分钟前
基于vue框架的宠物销售管理系统3m9h3(程序+源码+数据库+调试部署+开发环境)系统界面在最后面。
数据库
小菜yh24 分钟前
关于Redis
java·数据库·spring boot·redis·spring·缓存
Microsoft Word44 分钟前
数据库系统原理(第一章 数据库概述)
数据库·oracle
华为云开源1 小时前
openGemini 社区人才培养计划:助力成长,培养新一代云原生数据库人才
数据库·云原生·开源
kejijianwen4 小时前
JdbcTemplate常用方法一览AG网页参数绑定与数据寻址实操
服务器·数据库·oracle
编程零零七4 小时前
Python数据分析工具(三):pymssql的用法
开发语言·前端·数据库·python·oracle·数据分析·pymssql
高兴就好(石7 小时前
DB-GPT部署和试用
数据库·gpt
这孩子叫逆8 小时前
6. 什么是MySQL的事务?如何在Java中使用Connection接口管理事务?
数据库·mysql
Karoku0668 小时前
【网站架构部署与优化】web服务与http协议
linux·运维·服务器·数据库·http·架构
码农郁郁久居人下8 小时前
Redis的配置与优化
数据库·redis·缓存