Django5/Django5/settings.py

142 lines
4.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Django settings for Django5 project.
Generated by 'django-admin startproject' using Django 5.2.
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
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# 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 = 'django-insecure-7y(^f-&e%!(6-ku#19g8ywnn0w@@lm17cfal2e5om_1&vsyuxa'
# 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',
"helloWorld.apps.HelloworldConfig",
"user.apps.UserConfig",
"order.apps.OrderConfig"
]
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',
'helloWorld.mymid.md1.Md1',
]
# 主路由器的路径,可以修改
ROOT_URLCONF = 'Django5.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates',BASE_DIR / '/helloWorld/templates']
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
# 项目部署时Django的内置服务器将使用的WSGI应用程序对象的完整Python路径
WSGI_APPLICATION = 'Django5.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django',
'USER': 'django',
'PASSWORD': '123456789',
'HOST': '148.135.85.49',
'PORT': '3306',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
# 支持拔插的密码验证器可以一次性配置多个Django通过这些内置组件来避免用户设置的密码等级不足的问题
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/
# 语言配置项,英文'en-us' 中文'zh-Hans
LANGUAGE_CODE = 'zh-Hans'
# 当前服务端时区配置,世界时区'UTC' 中国时区'Asia/Shanghai'
TIME_ZONE = 'Asia/Shanghai'
# 项目开发完成后,可以选择向不同国家的用户提供服务,那么就需要支持国际化和本地化
USE_I18N = True
# 时区的处理方式设置为True的时候存储到数据库的时间是世界时间'UTC'
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.2/howto/static-files/
STATIC_URL = 'static/'
# 设置静态资源文件集合
# STATICFILES_DIRS = [BASE_DIR / 'static', BASE_DIR / 'helloworld/images']
# 设置媒体路由
MEDIA_URL = '/media/'
# 设置media目录的完整路径
MEDIA_ROOT = BASE_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'