I tried to use render to show the HTML edited on PyCharm, but when I entered the address: 127.0.0.1:8000/index/
, the following TemplateDoesNotExist
exception appeared:
TemplateDoesNotExist at /index/ index.html Request Method: GET Request URL: http://127.0.0.1:8000/index/ Django Version: 1.11.1 Exception Type: TemplateDoesNotExist Exception Value:index.html Exception Location: D:\python3.6.1\lib\site-packages\django\template\loader.py in get_template, line 25 Python Executable: D:\python3.6.1\python.exe Python Version: 3.6.1 Python Path:
['C:\Users\Administrator\guest', '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\site-packages'] Server time: Fri, 2 Jun 2017 03:30:58 +0000`TemplateDoesNotExist at /index/
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")
Screenshot of PyCharm:
I have tried some methods provided on StackOverflow, but they do not work. Is this exception caused by the wrong dirs? How can I deal with such situation?