From 58a93e1aa101eeaec9dbd291b9f3565b93547b16 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Thu, 14 Dec 2023 12:09:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=20=E5=90=AF=E5=8A=A8=E5=89=8D=E5=85=88?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=BF=81=E7=A7=BB=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/smartdoc/conf.py | 3 +++ apps/smartdoc/settings/base.py | 3 +-- config_example.yml | 8 ++++++-- main.py | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) 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")