This commit is contained in:
2026-08-25 19:02:52 +08:00
parent c65cc92386
commit 7ef8723c6b
2 changed files with 23 additions and 12 deletions

View File

@@ -1,18 +1,30 @@
"""
本地设置示例文件
生产环境本地设置
使用方法:复制为 local_settings.py 并按需修改
cp local_settings.example.py local_settings.py
此文件已在 .gitignore 中忽略,不会提交到仓库。
在此文件中覆盖 settings.py 中的任意配置。
"""
# 生产环境请设置
# import os
# SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'your-secret-key')
# ============ 安全配置 ============
# 生成方式: python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
SECRET_KEY = 'your-production-secret-key-here'
# DEBUG = False
DEBUG = False
# ALLOWED_HOSTS = ['www.yuangyaa.com', 'yuangyaa.com']
ALLOWED_HOSTS = ['www.yuangyaa.com', 'yuangyaa.com']
# 生产环境数据库PostgreSQL
# ============ 数据库配置 ============
# SQLite轻量级适合小规模站点
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
# }
# PostgreSQL推荐生产环境
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',

View File

@@ -11,7 +11,6 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -21,14 +20,14 @@ DATA_DIR = BASE_DIR / 'data'
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get(
'DJANGO_SECRET_KEY',
'django-insecure-g224%sp()h))26kj26pnnfoayu-knah+!)h9uzgqeece&6*clp'
)
# 生产环境请在 local_settings.py 中覆盖
SECRET_KEY = 'django-insecure-g224%sp()h))26kj26pnnfoayu-knah+!)h9uzgqeece&6*clp'
# SECURITY WARNING: don't run with debug turned on in production!
# 生产环境请在 local_settings.py 中设置为 False
DEBUG = True
# 生产环境请在 local_settings.py 中配置
ALLOWED_HOSTS = []
# Application definition