我试图用渲染上显示PyCharm编辑HTML,但是当我输入电子邮件地址:127.0.0.1:8000/index/
,以下TemplateDoesNotExist
例外出现:TemplateDoesNotExist错误(Python的3.6.1,Django的1.11.1,PyCharm)
TemplateDoesNotExist在/指数/ index.html的 请求 方法:GET 请求URL:http://127.0.0.1:8000/index/ Django的版本:1.11.1 异常类型:TemplateDoesNotExist 异常值:index.html的 异常位置:d:\ python3.6.1 \ LIB \站点包\ Django的\模板\ LO ader.py在get_template 25行 Python的可执行文件:d:\ python3.6.1 \ python.exe Python的版本:3.6.1 Python的路径:
[ 'C:\用户\管理员\客人', “d :\ python3.6.1 \ python36.zip', 'D:\ python3.6.1 \ DLLs', 'D:\ python3.6.1 \ lib', 'D:\ python3.6.1', 'D:\ python3.6.1 \ LIB \站点包] 服务器时间:星期五,2017年6月2日3点30分58秒+ 0000`TemplateDoesNotExist在/索引/
settings.py:
ROOT_URLCONF = 'guest.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
views.py:
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request,"index.html")
PyCharm的截图:
我曾尝试提供在计算器上的一些方法,但他们没有工作。这个异常是由错误的dirs引起的吗?我该如何处理这种情况?
_caused错误的dirs_ ...你没有任何目录:''DIRS':[]' –
你已经完成了'collectstatics'吗?你在'settings.py中设置了静态路径'文件?你把所有的模板放在静态模板文件夹中吗? –
@ PiyushS.Wanare你的评论的每一部分都是错误的。为什么collectstatic与模板有什么关系?为什么模板会在静态目录中? –