标签:files rod cts screen 收集 str director path 配置
1.模板文件
TEMPLATES = [
{
# 模板引擎,内置的模板引擎有:
# 1. ‘django.template.backends.django.DjangoTemplates‘
# 2. ‘django.template.backends.JInJa2.JInja2‘
# 你也可以使用非Django的模板引擎
‘BACKEND‘: ‘django.template.backends.django.DjangoTemplates‘,
# 引擎用于查找模板源文件的目录,按搜索顺序排列
‘DIRS‘: [os.path.join(BASE_DIR, ‘templates‘), os.path.join(BASE_DIR, "mobile_app/dist"),
os.path.join(BASE_DIR, "big_screen/screenpro/dist"), ],
# 引擎是否在已经安装的应用程序(的目录)内查看模板源文件
‘APP_DIRS‘: True,
# 传递给模板引擎(backend)的其他参数,不同引擎,可用的参数不一样
‘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‘,
# u"在模板变量中添加 {{ MEDIA_URL }}"
"django.template.context_processors.media",
# u"在模板变量中添加 {{ STATIC_URL }}"
"django.template.context_processors.static",
# 添加 移动标识 device
"prod_core.template.context_processors.mobile",
],
},
},
]
2.静态文件
# template模板上映射到静态文件的url
STATIC_URL = ‘/static/‘
# python manage.py collectstatic 命令收集静态文件的目录,将各个app目录下的static收集于项目目录下的static中
STATIC_ROOT = ‘static‘
# 放各个app的static目录及公共的static目录
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "mobile_app/dist/static/"),
os.path.join(BASE_DIR, "big_screen/screenpro/dist/static/")
]
STATICFILES_FINDERS = (
# 用来从 STATICFILES_DIRS 指定的路径中查找额外的静态文件
‘django.contrib.staticfiles.finders.FileSystemFinder‘,
# 从 INSTALLED_APPS 列表内的 APP 所在包的 static 目录中查找资源文件
‘django.contrib.staticfiles.finders.AppDirectoriesFinder‘,
# other finders.. css,js等文件压缩
‘compressor.finders.CompressorFinder‘,
)
3.媒体文件
# media目录,相当于设置媒体文件的绝对路径 MEDIA_ROOT = os.path.join(BASE_DIR, ‘media‘) # template模板上映射到媒体目录的url,相当于设置媒体文件的相对路径 MEDIA_URL = ‘/media/‘
标签:files rod cts screen 收集 str director path 配置
原文地址:https://www.cnblogs.com/konglingxi/p/9406757.html