|
|
|
@ -13,7 +13,6 @@ import datetime |
|
|
|
|
from pathlib import Path |
|
|
|
|
import sys, os |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'. |
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent |
|
|
|
|
|
|
|
|
@ -150,7 +149,6 @@ auth.User.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'auth.User |
|
|
|
|
""" |
|
|
|
|
AUTH_USER_MODEL = 'user.Myuser' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
REST_FRAMEWORK = { |
|
|
|
|
# 设置全局渲染模板 |
|
|
|
|
'DEFAULT_RENDERER_CLASSES': ( |
|
|
|
@ -166,7 +164,7 @@ REST_FRAMEWORK = { |
|
|
|
|
'EXCEPTION_HANDLER': 'common.myexception.my_exception_handler', |
|
|
|
|
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema', |
|
|
|
|
# 验证设置 |
|
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework_simplejwt.authentication.JWTAuthentication', ), |
|
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework_simplejwt.authentication.JWTAuthentication',), |
|
|
|
|
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',), |
|
|
|
|
} |
|
|
|
|
JWT_AUTH = { |
|
|
|
@ -184,3 +182,29 @@ SIMPLE_JWT = { |
|
|
|
|
# 跨域配置 |
|
|
|
|
CORS_ALLOW_CREDENTIALS = True # 跨域时是否携带cookie |
|
|
|
|
CORS_ORIGIN_ALLOW_ALL = True # 指定所有域名都可以访问后端接口 |
|
|
|
|
|
|
|
|
|
# CACHES = { |
|
|
|
|
# 'default': { |
|
|
|
|
# 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', |
|
|
|
|
# 'LOCATION': 'my_cache_table', |
|
|
|
|
# } |
|
|
|
|
# } |
|
|
|
|
|
|
|
|
|
CACHES = { |
|
|
|
|
'default': { |
|
|
|
|
'BACKEND': 'django_redis.cache.RedisCache', |
|
|
|
|
'LOCATION': 'redis://home.rogersun.cn:6379', |
|
|
|
|
'OPTIONS': { |
|
|
|
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient', |
|
|
|
|
'PASSWORD': 'Sxzgx1209', |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' |
|
|
|
|
SESSION_CACHE_ALIAS = 'default' |
|
|
|
|
|
|
|
|
|
REST_FRAMEWORK_EXTENSIONS = { |
|
|
|
|
'DEFAULT_CACHE_RESPONSE_TIMEOUT': 60, # 缓存时间60秒 |
|
|
|
|
'DEFAULT_USE_CACHE': 'default', # 默认缓存方式, 对应CACHE中的设置 |
|
|
|
|
} |
|
|
|
|