BASE_DIR
项目路径:默认是已经打开的主项目路径
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY
密钥
SECRET_KEY = '(dh&_fm2hfn9y)35!_6#$a7q%%^onoy=#-a8x18r4(6*8f(ani'
DEBUG
帮助调试,默认为True
DEBUG = True
DEBUG=False时
ALLOWED_HOSTS
允许访问的主机,默认是127.0.0.1
当关闭DEBUG后不能为空
ALLOWED_HOSTS = []
INSTALLED_APPS
注册子app
INSTALLED_APPS = ['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','book',# 'book.apps.BookConfig']
ROOT_URLCONF
路由配置文件路径
ROOT_URLCONF = 'bookmanager.urls'
TEMPLATES
模板配置
# TEMPLATES路径模板,BASE_DIR指当前目录
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',],},},
]
DATABASES
配置数据库模型,默认时sqllite3
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3',# 迁移数据库创建的路径'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),}
}
LANGUAGE_CODE
语言
# 设置为中文
LANGUAGE_CODE = 'zh-Hans'
TIME_ZONE
时区
TIME_ZONE = 'UTC'
STATIC_URL
静态资源
# 静态资源的路由
STATIC_URL = '/static/'
需要在DEBUG=True时,设置名为STATICFILES_DIRS的路径数据
STATICFILES_DIRS=[os.path.join(BASE_DIR,"static"),
]