164 lines
4.4 KiB
Python
164 lines
4.4 KiB
Python
"""
|
|
Django settings for pr_manager project.
|
|
|
|
Generated by 'django-admin startproject' using Django 5.1.6.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/5.1/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/5.1/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import configparser
|
|
from pathlib import Path
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
CONFIG_NAME = BASE_DIR / "config.ini"
|
|
|
|
# 加载配置文件: 开发可加载config.local.ini
|
|
_config = configparser.ConfigParser()
|
|
_config.read(CONFIG_NAME, encoding="utf-8")
|
|
|
|
sys.path.insert(0, os.path.join(BASE_DIR, "apps"))
|
|
sys.path.insert(1, os.path.join(BASE_DIR, "apps/utils"))
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = "django-insecure-$r6lfcq8rev&&=chw259o$0o7t-!!%clc2ahs3xg$^z+gkms76"
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = bool(int(_config["BASE"].get("DEBUG", "1")))
|
|
|
|
ALLOWED_HOSTS = ["*"]
|
|
CSRF_TRUSTED_ORIGINS = ["http://110.40.30.95:10008"]
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"simplepro",
|
|
"simpleui",
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"public",
|
|
"pr",
|
|
]
|
|
|
|
# 配置安全秘钥
|
|
SIMPLEPRO_SECRET_KEY = "2122113b39b44d33af54023436172730"
|
|
|
|
SIMPLEPRO_INFO = False
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
# "django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
"simplepro.middlewares.SimpleMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "pr_manager.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [BASE_DIR / 'templates'],
|
|
"APP_DIRS": True,
|
|
"OPTIONS": {
|
|
"context_processors": [
|
|
"django.template.context_processors.debug",
|
|
"django.template.context_processors.request",
|
|
"django.contrib.auth.context_processors.auth",
|
|
"django.contrib.messages.context_processors.messages",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "pr_manager.wsgi.application"
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
"pg": {
|
|
"ENGINE": "django.db.backends.postgresql",
|
|
"NAME": _config["DATABASE"].get("DB_NAME", "chat_ai_v2"),
|
|
"USER": _config["DATABASE"].get("DB_USER", "admin"),
|
|
"PASSWORD": _config["DATABASE"].get("DB_PASSWORD", "admin123456"),
|
|
"HOST": _config["DATABASE"].get("DB_HOST", "124.222.222.101"),
|
|
"PORT": int(_config["DATABASE"].get("DB_PORT", "5432")),
|
|
},
|
|
"sqlite": {
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
"NAME": BASE_DIR / "db.sqlite3",
|
|
},
|
|
}
|
|
|
|
DATABASES["default"] = DATABASES[_config["DATABASE"].get("DEFAULT", "sqlite")]
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
|
},
|
|
]
|
|
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/5.1/topics/i18n/
|
|
|
|
LANGUAGE_CODE = "zh-hans"
|
|
|
|
TIME_ZONE = "Asia/Shanghai"
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = False
|
|
|
|
# 全局时间格式化
|
|
DATETIME_FORMAT = "Y-m-d H:i:sO"
|
|
date_format = 'Y-m-d'
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
|
|
|
STATIC_URL = "/static/"
|
|
|
|
# 生产环境目录
|
|
STATIC_ROOT = BASE_DIR / "static"
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|