При попытке перехода по адресу http://127.0.0.1:8000/news/1
возникает ошибка:
TemplateDoesNotExist at /news/1
database/articles_detail.html
Request Method: GET
Request URL: http://127.0.0.1:8000/news/1
Django Version: 3.1.7
Exception Type: TemplateDoesNotExist
Exception Value:
database/articles_detail.html
Exception Location: D:\User\Python\web-app\venv\lib\site-packages\django\template\loader.py, line 47, in select_template
Python Executable: D:\User\Python\web-app\venv\Scripts\python.exe
Python Version: 3.9.2
Python Path:
['D:\\User\\GitHub\\Django_Lessons\\web-app\\web',
'C:\\Users\\OurCh\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip',
'C:\\Users\\OurCh\\AppData\\Local\\Programs\\Python\\Python39\\DLLs',
'C:\\Users\\OurCh\\AppData\\Local\\Programs\\Python\\Python39\\lib',
'C:\\Users\\OurCh\\AppData\\Local\\Programs\\Python\\Python39',
'D:\\User\\Python\\web-app\\venv',
'D:\\User\\Python\\web-app\\venv\\lib\\site-packages']
Server time: Fri, 09 Apr 2021 09:21:27 +0000
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.app_directories.Loader: D:\User\GitHub\Django_Lessons\web-app\web\main\templates\database\articles_detail.html (Source does not exist)
django.template.loaders.app_directories.Loader: D:\User\GitHub\Django_Lessons\web-app\web\database\templates\database\articles_detail.html (Source does not exist)
django.template.loaders.app_directories.Loader: D:\User\Python\web-app\venv\lib\site-packages\django\contrib\admin\templates\database\articles_detail.html (Source does not exist)
django.template.loaders.app_directories.Loader: D:\User\Python\web-app\venv\lib\site-packages\django\contrib\auth\templates\database\articles_detail.html (Source does not exist)
файл urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('', views.news_home, name='news_home'),
path('create', views.create, name='create'),
path('<int:pk>', views.NewsDetailView.as_view(), name='news-detail'),
]
класс NewsDetailView
в файле views.py:
class NewsDetailView(DetailView):
model = Articles
templates_name = 'database/details_views.html'
context_object_name = 'article'
файл details_views.html
:
{% extends 'main/layout.html' %}
{% block title %}
Новости на сайте
{% endblock %}
{% block content %}
<div class="features">
<h1>{{ article.title }}</h1>
<p>{{ article.date }}</p>
<p>{{ article.full_text }}</p>
</div>
{% endblock %}
articles_detail.html
существует?