From 209f18cd637c4ce27f594003f4205c5a8a552df0 Mon Sep 17 00:00:00 2001 From: Franklin-F Date: Sun, 13 Apr 2025 20:08:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E9=85=8D=E7=BD=AE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/settings.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/core/settings.py b/core/settings.py index 3ea8592..d66f251 100644 --- a/core/settings.py +++ b/core/settings.py @@ -9,9 +9,13 @@ https://docs.djangoproject.com/en/5.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/5.0/ref/settings/ """ - +import environ +import os from pathlib import Path +env = environ.Env() +environ.Env.read_env(os.path.join(BASE_DIR, '.env')) + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -85,18 +89,17 @@ WSGI_APPLICATION = 'core.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'tsreshub_db', - 'USER': 'tsreshub_prod', - 'PASSWORD': 'Tr5h$Prod!92@TsRH', - 'HOST': '39.101.135.56', - 'PORT': '3306', + 'NAME': env('DB_NAME'), + 'USER': env('DB_USER'), + 'PASSWORD': env('DB_PASSWORD'), + 'HOST': env('DB_HOST'), + 'PORT': env('DB_PORT'), 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", } } } - # Password validation # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators