setting.py
BASE_DIR # 项目运行的绝对路径
SECRET_KEY # 密钥 生产环境中使用
DEBUG # 开发模式
ALLOWED_HOSTS # 允许访问的主机 全部为 '*'
INSTALLED_APPS # 已安装的app
MIDDLEWARE # 中间件 面向切面编程
# 根路由
ROOT_URLCONF = 'helloDjango.urls'
# 模板
TEMPLATES
# 部署使用的:
WSGI_APPLICATION
# 数据库
DATABASES: SQLite
# 轻量级 嵌入式 的数据库, 常用于移动端
# 系统自带 认证器
AUTH_PASSWORD_VALIDATORS
# 语言编码
LANGUAGE_CODE =
'en-us' 'zh-hans'
# 时区
# utc同一时间
# Asia/Shanghai
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
### 关于app的注册
INSTALLED_APPS = ['helloApp',]
此时, django去已注册的app下找网页html
在项目下 -> templates 里的html不会被识别
需要在 TEMPLATES 中添加路径
不建议 :
E:\Jam's Folder\python\QF_900\Django\helloDjango\templates
建议:
os.path.join(BASE_DIR,'templates')
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR,'templates')
],
...
数据库
DATABASES: SQLite
# 轻量级 嵌入式 的数据库, 常用于移动端
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE':'django.db.backends.mysql',
'NAME':'spider_book',
'USER':'root',
'PASSWORD':'',
'HOST':'127.0.0.0',
'PORT':'3306',
}
}