Files
links/url_manager/settings.py
T
2024-11-03 10:11:25 +11:00

148 lines
3.6 KiB
Python

import os
from pathlib import Path
from django.utils.translation import gettext_lazy as _
import links.patches # 添加这一行在文件最上方
# 构建路径,如 BASE_DIR / 'subdir'
BASE_DIR = Path(__file__).resolve().parent.parent
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles', # Make sure this is here only once
'widget_tweaks',
'links',
'tailwind',
'new_theme',
'simplemde',
'markdown', # 只需要基本的markdown包
]
ROOT_URLCONF = 'url_manager.urls'
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware', # Make sure this is here
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(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',
],
},
},
]
# ... 其他设置 ...
# 添加以下基本设置(如果尚未存在)
SECRET_KEY = 'your-secret-key-here' # 请更改为一个安全的随机值
DEBUG = True
ALLOWED_HOSTS = ['*']
# 数据库设置(使用默认的SQLite配置)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': '/app/data/db.sqlite3', # Updated path
'NAME': BASE_DIR / 'data/db.sqlite3',
}
}
# 静态文件设置
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
# 默认自动字段类型
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# ... 其他设置 ...
LANGUAGES = [
('en', _('English')),
('zh-hans', _('Simplified Chinese')),
]
LOCALE_PATHS = [
BASE_DIR / 'locale',
]
LANGUAGE_CODE = 'en' # 设置默认语言为英语
USE_I18N = True
USE_L10N = True
USE_TZ = True
# ... 其他设置 ...
ROOT_URLCONF = 'url_manager.urls'
# ... 其他设置 ...
TAILWIND_APP_NAME = 'new_theme'
INTERNAL_IPS = [
"127.0.0.1",
]
# Add this at the end of the file
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
CSRF_TRUSTED_ORIGINS = os.environ.get('CSRF_TRUSTED_ORIGINS', 'http://localhost:8000').split(',')
# SimpleMDE 配置
SIMPLEMDE_OPTIONS = {
'placeholder': 'Type here...',
'status': False,
'autosave': {
'enabled': True,
'delay': 10000,
},
}
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'root': {
'handlers': ['console'],
'level': 'INFO',
},
'loggers': {
'django': {
'handlers': ['console'],
'level': 'INFO',
'propagate': False,
},
},
}