MySql设置:
pip install mysqlclient
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
# }
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'phone',
'USER': 'user',
'PASSWORD': 'password',
'HOST': '127.0.0.1',
'PORT': 3306,
'CONN_MAX_AGE': 5 * 60,
'OPTIONS': {'charset': 'utf8mb4'}
}
}
Redis
CACHE_DEFAULT_TIMEOUT = 60*5
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"PASSWORD":"password",
},
}
}