1
kaikai5601 6 天前 via iPhone
setting 里面设置没设置好吧,模板默认目录
|
![]() |
2
shuizhengqi 6 天前
报错都这么明显了,找不到模板。你自己 setting 里面路径没设对
|
3
4thmagi 6 天前
@kaikai5601 非常感谢。我在 settings.py 的 Templates[]中加了如下代码:
'DIRS': [os.path.join(BASE_DIR, 'templates')], 结果还是会报错。 我在百度上搜索了如何 django 设置模板默认目录,得到的方案是在末尾加一句 TEMPLATES_DIRS = [ os.path.join(BASE_DIR, "mysite\\templates").replace('\\','/'), ] 请问 django2.0 应该如何设置模板默认目录? |
![]() |
4
chengxiao 5 天前
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', 'django.template.context_processors.static', ], }, }, ] |