feat: 配置时间区域 启动前先执行迁移数据库

This commit is contained in:
shaohuzhang1 2023-12-14 12:09:11 +08:00
parent 4274504b31
commit 58a93e1aa1
4 changed files with 11 additions and 4 deletions

View File

@ -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'),

View File

@ -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

View File

@ -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

View File

@ -43,6 +43,7 @@ def perform_db_migrate():
def start_services():
management.call_command('migrate')
management.call_command('runserver',"0.0.0.0:8000")