TemplateDoesNotExist - уже добавлен каталог шаблонов в настройках и создан внутри проекта
Я создал проект "ProTwo" и приложение "appTwo", добавил каталог templates в настройках проекта и создал папку templates в проекте. Когда я рендерю views index.html, он показывает ошибку
app/views.py
'''
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
help_dict={'help_me':"HELP PAGE"}
return render(request,'appTwo/help.html',context=help_dict)
'''
app/urls.py
'''
from django.urls import path
from appTwo import views
urlpatterns = [
path('',views.index,name="index"),
]
'''
Project/settings.py
project/urls.py """ from django.contrib import admin from django.urls import path,include
urlpatterns = [
path('admin/', admin.site.urls),
path('appTwo/',include('appTwo.urls')),
]
"""
project/templates/appTwo/index.html
"""
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>appTwo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
</head>
<body>
{{ help_me }}
<script src="" async defer></script>
</body>
</html>
"""
Вы отображаете return render(request,'appTwo/help.html',context=help_dict)
и имя шаблона - "help.html", а ваш html-файл называется "index.html". Просто измените имена, и все будет исправлено!