首页 > 解决方案 > TemplateDoesNotExist 位于 /home/entry/index.html、entry/entry_list.html

问题描述

我需要一双额外的眼睛,我只是看不到错误,下面你可以看到所有必要的文件,我认为错误来自那里 这是我得到的错误

在那里你可以看到文件结构

视图.py

from django.shortcuts import render
from django.views.generic import ListView
from .models import Entry
class HomeView(ListView):
    model = Entry
    template_name='entries/index.html'

网址.py

from .views import HomeView
from django.urls import path

urlpatterns = [
    
    path('home/', HomeView.as_view(), name='blog-home')
]

基本网址.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('entries.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',
            ],
        },
    },
]

标签: django

解决方案


你需要在 settings.py 添加模板目录,改变这个

    'DIRS': [],

对此

    'DIRS': ['templates'],

在 settings.py 文件中,模板设置


推荐阅读