Issue
I am creating a simple website.and having kinda odd error TemplateDoesNotExist at /about/
but my homepage
working fine without TempaletDoesNotExist error. mine both home.html
and about.html
in same directory
and I tried many solutions with the reference of this answer
the actual problem is one URL is working and another one is not. please help me out thanks
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)
My templates<dir
>
/home/name/appname/mysite/templates/home.html
/home/name/appname/mysite/templates/about.html
app<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')
app<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',
],
},
},
]
Solution
you have a typo in your views.py
file in about view. Spell about.html
instead of about.hmtl
.
And that's it ;)
Answered By - Mubashar javed Answer Checked By - Willingham (WPSolving Volunteer)