Django settings 配置

Created
Sep 6, 2023 05:22 AM
Date
Sep 6, 2023
""" Django settings for singleBlog project. Generated by 'django-admin startproject' using Django 3.2.8. For more information on this file, see <https://docs.djangoproject.com/en/3.2/topics/settings/> For the full list of settings and their values, see <https://docs.djangoproject.com/en/3.2/ref/settings/> """ from pathlib import Path import simpleui, ckeditor import sys, os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent sys.path.insert(0, os.path.join(BASE_DIR, 'apps')) # Quick-start development settings - unsuitable for production # See <https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/> # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-3n0*8@=0qc465q+3j_$v73@l$358(85v09%295&&4jm9lr@(e5' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'ckeditor', 'simpleui', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', # 主应用 'user', # 用户中心 'other', # 其他 ] 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 = 'singleBlog.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', 'django.template.context_processors.media', # 用户上传 ], }, }, ] WSGI_APPLICATION = 'singleBlog.wsgi.application' # Database # <https://docs.djangoproject.com/en/3.2/ref/settings/#databases> DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'singleblog', 'HOST': '127.0.0.1', 'PORT': 3306, 'USER': 'root', 'PASSWORD': 'admin*123' } } # Password validation # <https://docs.djangoproject.com/en/3.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/3.2/topics/i18n/> LANGUAGE_CODE = 'zh-hans' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = False # Static files (CSS, JavaScript, Images) # <https://docs.djangoproject.com/en/3.2/howto/static-files/> STATIC_URL = '/static/' STATICFILES_DIRS = [BASE_DIR / 'static'] STATIC_ROOT = "/home/zic/桌面/singleBlog/singleBlog/static" # Default primary key field type # <https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field> DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') AUTHENTICATION_BACKENDS = { 'apps.user.views.MyBackend', } # 发送邮件配置 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # smpt服务地址 EMAIL_HOST = 'smtp.163.com' EMAIL_PORT = 25 # 发送邮件的邮箱 # ZDJTKDEFODMIXSQD EMAIL_HOST_USER = 'hybpjx@163.com' # 在邮箱中设置的客户端授权密码 EMAIL_HOST_PASSWORD = 'XDXXQCOFVKZSIQQQ' # 收件人看到的发件人 EMAIL_FROM = 'zic博客<hybpjx@163.com>' CKEDITOR_CONFIGS = { # django-ckeditor默认使用default配置 'default': { # 编辑器宽度自适应 'width': 'auto', 'height': '250px', # tab键转换空格数 'tabSpaces': 4, # 工具栏风格 'toolbar': 'Custom', # 工具栏按钮 'toolbar_Custom': [ # 表情 代码块 ['Smiley', 'CodeSnippet'], # 字体风格 ['Bold', 'Italic', 'Underline', 'RemoveFormat', 'Blockquote'], # 字体颜色 ['TextColor', 'BGColor'], # 链接 ['Link', 'Unlink'], # 列表 ['NumberedList', 'BulletedList'], # 最大化 ['Maximize'] ], # 加入代码块插件 'extraPlugins': ','.join(['codesnippet', 'widget', 'lineutils']), } }