Python Django 2:TemplateDoesNotExist即使文件放置正确
我在Django 2上遇到了一个有趣的问题 在我的Python Django 2:TemplateDoesNotExist即使文件放置正确,python,django,django-templates,Python,Django,Django Templates,我在Django 2上遇到了一个有趣的问题 在我的settings.py中,我写了以下内容: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': {
settings.py
中,我写了以下内容:
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',
],
},
},
]
之后,我在我的项目根文件夹中创建了文件夹模板
然后我创建了名为front
的应用程序,并将其添加到我的设置中。py
已安装的应用程序
:
在我的视图.py中,我添加了以下视图:
def index(request):
return render(request, 'front/index')
我已将其url分配如下:
url(r'^$', views.index, name='index'),
当我尝试访问此视图时,出现以下错误:
TemplateDoesNotExist at /
front/index
为什么会这样?我错过什么了吗?改变
def index(request):
return render(request, 'front/index')
到
def index(request):
return render(request, 'front/index.html')