diff --git a/apps/smartdoc/conf.py b/apps/smartdoc/conf.py index 271e100b5..aa90d2134 100644 --- a/apps/smartdoc/conf.py +++ b/apps/smartdoc/conf.py @@ -101,6 +101,9 @@ class Config(dict): def get_debug(self) -> bool: return self.get('DEBUG') if 'DEBUG' in self else True + def get_time_zone(self) -> str: + return self.get('TIME_ZONE') if 'TIME_ZONE' in self else 'Asia/Shanghai' + def get_db_setting(self) -> dict: return { "NAME": self.get('DB_NAME'), diff --git a/apps/smartdoc/settings/base.py b/apps/smartdoc/settings/base.py index 33bd31ad0..b8f84f8e4 100644 --- a/apps/smartdoc/settings/base.py +++ b/apps/smartdoc/settings/base.py @@ -15,7 +15,6 @@ BASE_DIR = Path(__file__).resolve().parent.parent # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-g1u*$)1ddn20_3orw^f+g4(i(2dacj^awe*2vh-$icgqwfnbq(' - # SECURITY WARNING: don't run with debug turned on in production! DEBUG = CONFIG.get_debug() @@ -154,7 +153,7 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = CONFIG.get_time_zone() USE_I18N = True diff --git a/config_example.yml b/config_example.yml index f88f2910c..091fc34a5 100644 --- a/config_example.yml +++ b/config_example.yml @@ -8,9 +8,13 @@ EMAIL_HOST_USER: EMAIL_HOST_PASSWORD: # 数据库链接信息 -DB_NAME: smart-doc +DB_NAME: maxkb DB_HOST: localhost DB_PORT: 5432 DB_USER: root -DB_PASSWORD: xxx +DB_PASSWORD: xxxxxxx DB_ENGINE: django.db.backends.postgresql_psycopg2 + +DEBUG: false + +TIME_ZONE: Asia/Shanghai diff --git a/main.py b/main.py index 5fbb24c29..237efdc3a 100644 --- a/main.py +++ b/main.py @@ -43,6 +43,7 @@ def perform_db_migrate(): def start_services(): + management.call_command('migrate') management.call_command('runserver',"0.0.0.0:8000")