1. mysql: 安装:pip install mysqlclient
# 在settings.py中配置
DATABASES = {
'default': { # 写(主机)
'ENGINE': 'django.db.backends.mysql',
'NAME': 'root',
'USER': 'mydb',
'PASSWORD': '123456',
'HOST': 'localhost',
'PORT': '3306',
}
}
2.redis:安装:pip install django-redis
# 配置Redis数据库
CACHES = {
"default": { # 默认
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/0",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
"session": { # session
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.