If you go to the web page, you can see some stuff that's there to help you debug stuff like this. Just underneath the error you quote, there's this bit:
So, Django is telling you exactly where it looked for your template Kappa/index.html. The first one is the place it looked based on the TEMPLATE_PATH you set -- it's looking for the file inside /home/KTruong88/Kappa_Ranks/templates/. The next two attempts were looking inside your installed Django apps. It only lists two, the standard Django admin and Django auth apps. So if your template file is inside the template subdirectory of one of your own apps, then that suggests that your app isn't on the INSTALLED_APPS list in your Django settings.
I still don't get what I'm supposed to change here. When I look at /home/KTruong88/Kappa_Ranks/templates/Kappa folder, I see index.html clearly there. I check my settings.py file too and it definitely is in the installed apps section too at /home/KTruong88/Kappa_Ranks/Kappa_Ranks/settings.py.
I also edited my static files section with /templates/ as url and the path as /home/KTruong88/Kappa_Ranks/templates.
Perhaps it's a case problem? On PythonAnywhere (like most Unix-based environments) directory names are case sensitive; if your local setup is on Windows or another case-insensitive OS then things would work there but wouldn't here.
So, for example, if your template is in /home/KTruong88/Kappa_Ranks/templates/kappa rather than /home/KTruong88/Kappa_Ranks/templates/Kappa then the template could be found on Windows, but not on Unix.
If you're sure that's not the problem, can I take a look at your code? We can see it from our side but we always ask permission first.
It's the case of the templates directory inside /home/KTruong88/Kappa_Ranks/ -- it's called Templates with a capital T, not templates. If you rename it then it should all work fine.
The complicated thing is going to be fixing that in Git, which can be a bit awkward when you want to change the case of a directory name. I've found the best way is to do it as two separate checkins; firstly git mv the "Templates" directory to something like "temp-templates", commit that, and then git mv "temp-templates" to "templates", then commit that.
My heart just skipped. It works. Thanks for the help, I found out the templates was supposed to be capitalized.
Edit: sorry, should have triple checked before posting again. Will definitely fix the git thing too right now
Template-loader postmortem Django tried loading these templates, in
this order:
(Source does not exist)
django.template.loaders.app_directories.Loader: /home/khizirsiddiqui/my-first-blog/myvenv/lib/python3.5/site-packages/django/contrib/auth/templates/blog\post_list.html
(Source does not exist)
But my template is in my-first-blog/blog/.
How should I put the path for my templates in settings.py, should it must be a direct path or the virtualenv path.
Could you please give an example.
Hello,
I am new to the python anywhere and i'm getting below exception,
"TemplateDoesNotExist at /"
Here is the location=("Exception Location:/home/Kishor123/.virtualenvs/myenv/lib/python3.8/site-
packages/django/template/loader.py in get_template, line 19")
Could you please assist me here?
You do not have a template with the filename that you are trying to use in any of the places that you have told Django to look for templates. The exception page that Django generates has additional information that you can use to debug. First, in the "Exception value" field at the top, it will tell you the name of the template that it's looking for. Second, in the "template loader postmortem" section, it will show you which directory it looked in to find the template. If you do not have a template file with the correct name in any of the listed directories, then Django cannot find your template.
I dont get it. I have a several templates in same directory. Some of them is work fine, some (like this one) - no. Can u help me please?
[edit by admin: formatting]
If you look at the error message on your site, in the stack trace you will see this:
{%extends"base_templete.html "%}
Note that there is a space in between the template name and the close quote. This means that Django will be looking for a template file with a space at the end, and your file (I assume) doesn't have a space at the end of its name.
If you fix your extends statement so that it doesn't have that extra space, it should work fine. Don't forget to reload the website on the "Web" page after making the fix.
I'm trying to deploy my first Django project on pythonanywhere but facing a problem to load base.html.
see your url.py and or your views.py
check the path of ur index.html. if it is under templates folder
template_name= index.html
but if it is under your app or under another folder u need to specify the correct path for the template
template_name= whatever_your _folder_is/index.html
I'm trying to deploy my first Django project on pythonanywhere but facing a problem to load base.html.
Template loader postmortem
Django tried loading these templates, in this order:
Using engine django:
* django.template.loaders.filesystem.Loader: /home/Ameeru/django-deployment-example/first_level/template/basic_app\index.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /home/Ameeru/.virtualenvs/django3/lib/python3.6/site-packages/django/contrib/admin/templates/basic_app\index.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /home/Ameeru/.virtualenvs/django3/lib/python3.6/site-packages/django/contrib/auth/templates/basic_app\index.html (Source does not exist)
Traceback (most recent call last):
File "/home/Ameeru/.virtualenvs/django3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/Ameeru/.virtualenvs/django3/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/Ameeru/.virtualenvs/django3/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, callback_args, *callback_kwargs)
File "/home/Ameeru/django-deployment-example/first_level/first_app/views.py", line 8, in index
return render(request,'basic_app\index.html',{'name':'user,Welcome you'})
File "/home/Ameeru/.virtualenvs/django3/lib/python3.6/site-packages/django/shortcuts.py", line 19, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "/home/Ameeru/.virtualenvs/django3/lib/python3.6/site-packages/django/template/loader.py", line 61, in render_to_string
template = get_template(template_name, using=using)
File "/home/Ameeru/.virtualenvs/django3/lib/python3.6/site-packages/django/template/loader.py", line 19, in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
Exception Type: TemplateDoesNotExist at /
Exception Value: basic_app\index.html
You all are great with support, I really appreciate it. I'm also having a TemplateDoesNotExist error on a django 3.1.1 site and I would appreciate your advice. My traceback is here.
It seems like the problem is that my template directory isn't being loaded but I can't figure out why:
Template loader postmortem
Django tried loading these templates, in this order:
Using engine django:
* django.template.loaders.filesystem.Loader: /home/robline/skip/templates/base.html (Source does not exist)
* django.template.loaders.filesystem.Loader: /home/robline/pep/templates/base.html (Source does not exist)
* django.template.loaders.filesystem.Loader: /skip/templates/base.html (Source does not exist)
* django.template.loaders.filesystem.Loader: /pep/templates/base.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/contrib/admin/templates/base.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/contrib/auth/templates/base.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django_extensions/templates/base.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /home/robline/robline.pythonanywhere.com/pep/templates/base.html (Source does not exist)
Traceback (most recent call last):
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/base.py", line 170, in render
return self._render(context)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/base.py", line 162, in _render
return self.nodelist.render(context)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/base.py", line 938, in render
bit = node.render_annotated(context)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/base.py", line 905, in render_annotated
return self.render(context)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/loader_tags.py", line 127, in render
compiled_parent = self.get_parent(context)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/loader_tags.py", line 124, in get_parent
return self.find_template(parent, context)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/loader_tags.py", line 104, in find_template
template_name, skip=history,
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/engine.py", line 129, in find_template
raise TemplateDoesNotExist(name, tried=tried)
The above exception (base.html) was the direct cause of the following exception:
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/core/handlers/base.py", line 202, in _get_response
response = response.render()
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/response.py", line 83, in rendered_content
return template.render(context, self._request)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/backends/django.py", line 63, in render
reraise(exc, self.backend)
File "/home/robline/.virtualenvs/robline.pythonanywhere.com/lib/python3.6/site-packages/django/template/backends/django.py", line 84, in reraise
raise new from exc
Exception Type: TemplateDoesNotExist at /
Exception Value: base.html
In the error page, there will be a template loader post-mortem that will tell you where Django was looking for your templates. Make sure that the directory where your template is is in the list and make sure that the casing for the entire path matches the casing for the directories and files on the disk.
In the error page, there will be a template loader post-mortem that will tell you where Django was looking for your templates. Make sure that the directory where your template is is in the list and make sure that the casing for the entire path matches the casing for the directories and files on the disk.
so for everyone face this issues... this is the solution
go to ur settings.py nd scroll to where u have templates
so the issue here is django doesnt knw what url to go because its looking for it.. nd remember this is a different work space(pythonanywhere) unlike our localhost
so simply add the url path to ur settings.py which u can find if u navigate to the file section
/home/user_name/project_name/templates/
now for u to load ur static files go to file section scroll down till u find static and add this to the path
/home/user_name/project_name/static
and /static/ to url depending on how u did urs
happy coding hope this helps.....
I am having the same problem. My app works fine locally with my Django project on Windows but not after deploying to Python Anywhere. I can access my first app login page on PA which extends a html file called "layout1.html". After logging in, the index.html page extends a html page named "layout2.html" which cannot be found. Both template html files are in the same directory. Any help with this would be much appreciated.
The template that cannot be found is at the following location:
/home/conordore/mma-client-portal/mma_dashboard/templates/mma_dashboard/layout2.html
Here is part of my settings.py file.
TEMPLATES = [
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['/home/conordore/mma-client-portal/mma_dashboard/templates'],
'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',
TemplateDoesNotExist at /mma_dashboard/
mma_dashboard/layout2.html
Request Method: GET
Request URL: https://conordore.pythonanywhere.com/mma_dashboard/
Django Version: 4.1.6
Exception Type: TemplateDoesNotExist
Exception Value:
mma_dashboard/layout2.html
Exception Location: /home/conordore/.virtualenvs/venv/lib/python3.10/site-packages/django/template/backends/django.py, line 85, in reraise
Raised during: mma_dashboard.views.index
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.10.5
Python Path:
['/var/www',
'/var/www',
'/usr/local/lib/python310.zip',
'/usr/local/lib/python3.10',
'/usr/local/lib/python3.10/lib-dynload',
'/home/conordore/.virtualenvs/venv/lib/python3.10/site-packages',
'/home/conordore/mma-client-portal']
Server time: Thu, 09 Mar 2023 19:50:41 +0000
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.filesystem.Loader: /home/conordore/mma-client-portal/mma_dashboard/templates/mma_dashboard/layout2.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/conordore/.virtualenvs/venv/lib/python3.10/site-packages/django/contrib/admin/templates/mma_dashboard/layout2.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/conordore/.virtualenvs/venv/lib/python3.10/site-packages/django/contrib/auth/templates/mma_dashboard/layout2.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/conordore/mma-client-portal/mma_dashboard/templates/mma_dashboard/layout2.html (Source does not exist)
Error during template rendering
In template /home/conordore/mma-client-portal/mma_dashboard/templates/mma_dashboard/index.html, error at line 1
Hi all, i am new in Python and have same problem. My app work in local on window and not work in PA.
TemplateDoesNotExist at /
learning_log\index.xhtml
i also check the path and it is correct.
Using engine django:
django.template.loaders.app_directories.Loader: /home/king1982/learninglog/learning_logs/templates/learning_log\index.xhtml (Source does not exist)
django.template.loaders.app_directories.Loader: /home/king1982/learninglog/accounts/templates/learning_log\index.xhtml (Source does not exist)
hi i revised the it still not work.
However the base.xhtml is insert in index.xhtml, i had redo it and now dont know why is working.
thank for your help.
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.filesystem.Loader: /home/SDavis/pmportfolio/homepage.html (Source does not exist)
django.template.loaders.filesystem.Loader: /home/SDavis/templates/homepage.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/django/contrib/admin/templates/homepage.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/django/contrib/auth/templates/homepage.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/bootstrap5/templates/homepage.html (Source does not exist)
Traceback Switch to copy-and-paste view
/home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/django/core/handlers/exception.py, line 47, in inner
response = get_response(request) …
▶ Local vars
/home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/django/core/handlers/base.py, line 181, in _get_response
response = wrapped_callback(request, callback_args, *callback_kwargs) …
▶ Local vars
/home/SDavis/pmportfolio/portfolio/views.py, line 8, in homepage
return render(request, 'homepage.html') …
▶ Local vars
/home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/django/shortcuts.py, line 19, in render
content = loader.render_to_string(template_name, context, request, using=using) …
▶ Local vars
/home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/django/template/loader.py, line 61, in render_to_string
template = get_template(template_name, using=using) …
▶ Local vars
/home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/django/template/loader.py, line 19, in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
I have a project named portfoliowebsite in which there is a templates folder which contains homepage.html . I have been trying for sometime now but to no avail. Do assist.
However, your templates are in the directory /home/SDavis/pmportfolio/templates. If you remove the extra portfoliowebsite/ from the location in settings.py, that should fix the issue.
Good day, i have this same problems but i went through all the solution and none is working for me. I have been stuck on this for 3 days now. I receive an error that templates does not exist.
Template-loader postmortem
Django tried loading these templates, in this order:
It is looking for the index, (/home/Vke33/vikolee.github.io/index.html) i tried add templates to the end of the vikolee.github.io before the index.html in wsgi file. But the error response i get is that Something went wrong. Please help me
Sorry, we have had to rate-limit your feedback sending. Please try again in a few moments...
Thanks for the feedback! Our tireless devs will get back to you soon.