Я создаю простой веб-сайт и имею странную ошибку TemplateDoesNotExist at /about/
, но мой homepage
работает нормально без ошибки TempaletDoesNotExist. мои home.html
и about.html
в одном и том же directory
, и я попробовал много решений со ссылкой на этот ответ , реальная проблема в том, что один URL работает, а другой - нет. Пожалуйста, помогите мне спасибо
TemplateDoesNotExist at /about/
about.hmtl
Request Method: GET
Request URL: https://www.appname./about/
Django Version: 2.2.9
Exception Type: TemplateDoesNotExist
Exception Value:
about.hmtl
Exception Location: /home/name/virtualenv/appname/3.5/lib/python3.5/site-packages/django/template/loader.py in get_template, line 19
Python Executable: /home/name/virtualenv/appname/3.5/bin/python3.5_bin
Python Version: 3.5.7
Python Path:
['/home/name/appname',
'/opt/passenger-5.3.7-4.el6.cloudlinux/src/helper-scripts',
'/home/name/virtualenv/appname/3.5/lib64/python35.zip',
'/home/name/virtualenv/appname/3.5/lib64/python3.5',
'/home/name/virtualenv/appname/3.5/lib64/python3.5/plat-linux',
'/home/name/virtualenv/appname/3.5/lib64/python3.5/lib-dynload',
'/opt/alt/python35/lib64/python3.5',
'/opt/alt/python35/lib/python3.5',
'/home/name/virtualenv/appname/3.5/lib/python3.5/site-packages']
Server time: Sun, 3 May 2020 04:48:46 +0000
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.app_directories.Loader: /home/name/virtualenv/appname/3.5/lib/python3.5/site-packages/django/contrib/admin/templates/about.hmtl (Source does not exist)
django.template.loaders.app_directories.Loader: /home/name/virtualenv/appname/3.5/lib/python3.5/site-packages/django/contrib/auth/templates/about.hmtl (Source does not exist)
django.template.loaders.app_directories.Loader: /home/name/appname/mysite/templates/about.hmtl (Source does not exist)
Мои шаблоны <<code>dir>
/home/name/appname/mysite/templates/home.html
/home/name/appname/mysite/templates/about.html
app <<code>views.py>
from django.shortcuts import render
from django.http import HttpResponse
def homepage(request):
return render(request=request,template_name='home.html')
def about(request):
return render(request=request,template_name='about.hmtl')
приложение <<code>urls.py>
from django.conf.urls import include, url
from django.contrib import admin
from django.urls import path
from . import views
app_name = "bugengine"
urlpatterns = [
url(r'^$', views.homepage, name="homepage"),
url(r'^about/',views.about, name="about"),
]
setting.py
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',
],
},
},
]