render传入两个参数后报了找不到templates模板,如图


请问老师为什么会找不到django.templates模板呢


请问老师为什么会找不到django.templates模板呢
2017-01-16
问题已解决,遇到这个问题的童鞋可以参考下面:####这点老师居然没讲到,幸好及时填坑了
出现这个问题原因在于python的版本问题,我本地是3.5,django 1.10.5
如图:

路径是/django/template/ 注意这里没有's',所以日志才会打印出
No module named 'django.templates'
解决方案如下,进到setting文件下,找到TEMPLATES,移除's',可参照如下代码
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',
],
},
},
]
举报