fix some bugs && change push way
This commit is contained in:
0
config/__init__.py
Normal file
0
config/__init__.py
Normal file
18
config/asgi.py
Normal file
18
config/asgi.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
ASGI config for myblog project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
# 将 apps/ 加入 Python 路径
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'apps'))
|
||||
|
||||
application = get_asgi_application()
|
||||
25
config/local_settings.example.py
Normal file
25
config/local_settings.example.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
本地设置示例文件
|
||||
使用方法:复制为 local_settings.py 并按需修改
|
||||
cp local_settings.example.py local_settings.py
|
||||
"""
|
||||
|
||||
# 生产环境请设置
|
||||
# import os
|
||||
# SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'your-secret-key')
|
||||
|
||||
# DEBUG = False
|
||||
|
||||
# ALLOWED_HOSTS = ['www.yuangyaa.com', 'yuangyaa.com']
|
||||
|
||||
# 生产环境数据库(PostgreSQL)
|
||||
# DATABASES = {
|
||||
# 'default': {
|
||||
# 'ENGINE': 'django.db.backends.postgresql',
|
||||
# 'NAME': 'blog',
|
||||
# 'USER': 'blog_user',
|
||||
# 'PASSWORD': 'your_password',
|
||||
# 'HOST': 'localhost',
|
||||
# 'PORT': '5432',
|
||||
# }
|
||||
# }
|
||||
193
config/settings.py
Normal file
193
config/settings.py
Normal file
@@ -0,0 +1,193 @@
|
||||
"""
|
||||
Django settings for myblog project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 5.2.4.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
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
|
||||
DATA_DIR = BASE_DIR / 'data'
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# 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'
|
||||
)
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'blog',
|
||||
'mdeditor',
|
||||
]
|
||||
|
||||
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',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'config.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'config.wsgi.application'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/5.2/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.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'zh-Hans'
|
||||
TIME_ZONE = 'Asia/Shanghai'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = DATA_DIR / 'static'
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = DATA_DIR / 'media'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
"https://www.yuangyaa.com",
|
||||
"http://www.yuangyaa.com",
|
||||
"http://yuangyaa.com",
|
||||
"https://yuangyaa.com",
|
||||
]
|
||||
|
||||
# 添加 MDEditor 配置
|
||||
MDEDITOR_CONFIGS = {
|
||||
'default': {
|
||||
'width': '100%',
|
||||
'height': 700,
|
||||
'toolbar': ["undo", "redo", "|",
|
||||
"bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|",
|
||||
"h1", "h2", "h3", "h5", "h6", "|",
|
||||
"list-ul", "list-ol", "hr", "|",
|
||||
"link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime",
|
||||
"emoji", "html-entities", "pagebreak", "goto-line", "|", "help", "info",
|
||||
"||", "preview", "watch", "fullscreen"],
|
||||
'upload_image_formats': ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
|
||||
'image_folder': 'editor',
|
||||
'theme': 'default',
|
||||
'preview_theme': 'default',
|
||||
'editor_theme': 'default',
|
||||
'toolbar_autofixed': True,
|
||||
'search_replace': True,
|
||||
'emoji': True,
|
||||
'tex': False,
|
||||
'language': 'zh',
|
||||
'focus': False,
|
||||
'auto_height': False,
|
||||
}
|
||||
}
|
||||
|
||||
X_FRAME_OPTIONS = 'SAMEORIGIN'
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': '{levelname} {asctime} {module} {message}',
|
||||
'style': '{',
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'file': {
|
||||
'level': 'WARNING',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': DATA_DIR / 'logs' / 'django.log',
|
||||
'maxBytes': 1024 * 1024 * 5,
|
||||
'backupCount': 5,
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'handlers': ['file'],
|
||||
'level': 'WARNING',
|
||||
},
|
||||
}
|
||||
|
||||
# settings.py 末尾加上这段
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
31
config/urls.py
Normal file
31
config/urls.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
URL configuration for myblog project.
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/5.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('mdeditor/', include('mdeditor.urls')),
|
||||
# 包含blog应用的URL
|
||||
path('', include('blog.urls')),
|
||||
]
|
||||
|
||||
# 添加媒体文件URL配置 - 确保在DEBUG和生产环境都能正确处理媒体文件
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
18
config/wsgi.py
Normal file
18
config/wsgi.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
WSGI config for myblog project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
# 将 apps/ 加入 Python 路径
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'apps'))
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user