refect: settings里增加配置
This commit is contained in:
parent
515d0b5c17
commit
847cdc76a4
|
@ -13,17 +13,19 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
|
|||
from datetime import datetime, timedelta
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
from . import conf
|
||||
from django.core.cache import cache
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
||||
|
||||
SYS_JSON_PATH = os.path.join(BASE_DIR, 'server/conf.json')
|
||||
|
||||
|
||||
def get_sysconfig(reload=False):
|
||||
config = cache.get('system_config', None)
|
||||
if config is None or reload:
|
||||
|
@ -36,6 +38,7 @@ def get_sysconfig(reload=False):
|
|||
return config
|
||||
return config
|
||||
|
||||
|
||||
def update_dict(dict1, dict2):
|
||||
for key, value in dict2.items():
|
||||
if key == 'apk_file': # apk_file拷贝到固定位置
|
||||
|
@ -46,6 +49,7 @@ def update_dict(dict1, dict2):
|
|||
else:
|
||||
dict1[key] = value
|
||||
|
||||
|
||||
def update_sysconfig(new_dict):
|
||||
config = get_sysconfig()
|
||||
update_dict(config, new_dict)
|
||||
|
@ -56,6 +60,7 @@ def update_sysconfig(new_dict):
|
|||
# 重启时需要reload 不能这样操作, 会使缓存有问题,我也不知道为什么
|
||||
# get_sysconfig(reload=True)
|
||||
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = conf.SECRET_KEY
|
||||
|
||||
|
|
Loading…
Reference in New Issue