Forums

TemplateDoesNotExist

Trying to launch my first web app on PA and things just aren't working when going from local to PA for some reason.

My Template path is settings.py is

 import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates')
TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [TEMPLATE_PATH],
    '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',
        ],
    },
},

]

and my app is included in the installed_apps section of settings.py. How do I fix this?

TemplateDoesNotExist at /Kappa/

Kappa/index.html

Request Method:     GET
Request URL:    http://ktruong88.pythonanywhere.com/Kappa/
Django Version:     1.8.4
Exception Type:     TemplateDoesNotExist
Exception Value:

Kappa/index.html

Exception Location:     /home/KTruong88/.virtualenvs/Kappa/lib/python3.4/site-packages/django/template/loader.py in get_template, line 46
Python Executable:  /usr/local/bin/uwsgi
Python Version:     3.4.0
Python Path:

['/var/www',
 '.',
 '',
 '/var/www',
 '/home/KTruong88/.virtualenvs/Kappa/lib/python3.4',
 '/home/KTruong88/.virtualenvs/Kappa/lib/python3.4/plat-x86_64-linux-gnu',
 '/home/KTruong88/.virtualenvs/Kappa/lib/python3.4/lib-dynload',
 '/usr/lib/python3.4',
 '/usr/lib/python3.4/plat-x86_64-linux-gnu',
 '/home/KTruong88/.virtualenvs/Kappa/lib/python3.4/site-packages',
 '/home/KTruong88/Kappa_Ranks/']

Server time:    Sun, 4 Oct 2015 15:40:03 +0000

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:

Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/KTruong88/Kappa_Ranks/templates/Kappa/index.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/home/KTruong88/.virtualenvs/Kappa/lib/python3.4/site-packages/django/contrib/admin/templates/Kappa/index.html (File does not exist)
/home/KTruong88/.virtualenvs/Kappa/lib/python3.4/site-packages/django/contrib/auth/templates/Kappa/index.html (File does not exist)

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.

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'Kappa',
)

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.

I would love for you to take a look at my code. I did a double check and I've kept my project names and app names capitalized and I don't remember changing any names/capitalizations when I cloned it from github either.

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

Excellent, glad I could help!

Hello, I am getting the same problem, but can not work out with the solution. Can you help me?

Can you provide a bit more information?

Sorry. I just deleted the whole app and restarted with the tutorial again.

Here it is (again):

Template-loader postmortem Django tried loading these templates, in this order:

Using engine django:

django.template.loaders.app_directories.Loader: /home/khizirsiddiqui/my-first-blog/myvenv/lib/python3.5/site-packages/django/contrib/admin/templates/blog\post_list.html

(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/.

That's a strange path. Could one of your settings.py entries for the template config be missing a comma between two strings in a list?

It is working on my Windows

PythonAnywhere is not running on Windows. Your paths need to be valid Linux paths and a backslash is not valid (Linux uses forward slashes as path separators). My guess is you've got a Windows-y path in your settings somewhere.

How do I search that 'Windows-y'?

Thanks, it is now working with the forward slash

Excellent, thanks for confirming!

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.

the direct path, not the virtualenv path.

99% of the time you shouldn't need to add any template paths to settings.py. if you just keep your templates in a folder called "templates" inside one of your own apps (and it's in INSTALLED_APPS), then django will find it automatically.

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.

It works and my website is working fine now. Thanks for your help!

Great! Glad to help.

Hello. Same is here.

TemplateDoesNotExist at /main/pp/
base_templete.html 
Request Method: GET
Request URL:    http://orakio3.pythonanywhere.com/main/pp/
Django Version: 2.2.12
Exception Type: TemplateDoesNotExist
Exception Value:    
base_templete.html 
Exception Location: /home/orakio3/.virtualenvs/orakio3.pythonanywhere.com/lib/python3.5/site-packages/django/template/backends/django.py in reraise, line 84
Python Executable:  /usr/local/bin/uwsgi
Python Version: 3.5.9
Python Path:    
['/home/orakio3/orakio3.pythonanywhere.com/PS/PhantasyStar',
 '/var/www',
 '.',
 '',

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.

Omg, its all working now, what a noob i am. Thank you, God

Glad we could get a solution for you :-)

I'm trying to deploy my first Django project on pythonanywhere but facing a problem to load base.html.

this error is displaying:

TemplateDoesNotExist at /
base.html
Request Method: GET
Request URL:    http://adilijaz02.pythonanywhere.com/
Django Version: 3.0.4
Exception Type: TemplateDoesNotExist
Exception Value:    
base.html
Exception Location: /home/adilijaz02/.virtualenvs/venv/lib/python3.8/site-packages/django/template/backends/django.py in reraise, line 84
Python Executable:  /usr/local/bin/uwsgi
Python Version: 3.8.0
Python Path:    
['/var/www',
 '.',
 '',
 '/var/www',
 '/home/adilijaz02/.virtualenvs/venv/lib/python38.zip',
 '/home/adilijaz02/.virtualenvs/venv/lib/python3.8',
 '/home/adilijaz02/.virtualenvs/venv/lib/python3.8/lib-dynload',
 '/usr/lib/python3.8',
 '/home/adilijaz02/.virtualenvs/venv/lib/python3.8/site-packages',
 '/home/adilijaz02/softdac']
Server time:    Fri, 22 May 2020 14:55:38 +0000
Template-loader postmortem
Django tried loading these templates, in this order:

Using engine django:

django.template.loaders.app_directories.Loader: /home/adilijaz02/softdac/softdacapp/templates/base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/adilijaz02/.virtualenvs/venv/lib/python3.8/site-packages/django/contrib/admin/templates/base.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/adilijaz02/.virtualenvs/venv/lib/python3.8/site-packages/django/contrib/auth/templates/base.html (Source does not exist)

[edit by admin: formatting]

Where have you stored your file 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.

this error is displaying: Django Version: 3.0.8 Python Version: 3.6.9 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'first_app'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

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

It looks like you're using a backslash (\) somewhere in your code, where you should be using a forward slash (/).

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:

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)

The parts I think are relevant in settings.py include:

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

ALLOWED_HOSTS = ['127.0.0.1', '.pythonanywhere.com']

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_extensions',
    'pep'
]

ROOT_URLCONF = 'skip.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['skip/templates',
                 'pep/templates',
                 '/skip/templates',  # <<<
                 '/pep/templates'],  # <<< I added these two lines to try to brute force the pathing but it didn't work

The home page pattern in urls.py is below, and I do get to the correct template when I access home:

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.PEPaspectListView.as_view(), name='home'),
    re_path(r'^pep/', include('pep.urls')),
]

If I activate my virtual environment, run shell_plus. and import settings, it works fine with no traceback.

Could you copy/paste the traceback here in the forums? That link doesn't work for me for some reason.

Happy to, Giles! Thanks.

Environment:

Request Method: GET Request URL: http://robline.pythonanywhere.com/

Django Version: 3.1.1 Python Version: 3.6.9 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions', 'pep'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

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)

Template error: In template /home/robline/robline.pythonanywhere.com/pep/templates/pep_list.html, error at line 1 base.html 1 : {% extends "base.html" %} 2 : {% block title %}PEP Badge List{% endblock %} 3 : 4 : {% block extra-css %} 5 : <style> 6 : body { 7 : font-family: Sans-serif; 8 : font-size: 11px; 9 : } 10 : 11 : .slice {

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

the two lines you would have to add to "bruteforce" would be something like /home/robline/path/to/your/templates/dir/skip/templates

TemplateDoesNotExist at /view_mynotes usernavigation.html Request Method: GET Request URL: https://aagam1.pythonanywhere.com/view_mynotes Django Version: 3.1.4 Exception Type: TemplateDoesNotExist Exception Value:
usernavigation.html Exception Location: /home/aagam1/.virtualenvs/test/lib/python3.6/site-packages/django/template/backends/django.py, line 84, in reraise Python Executable: /usr/local/bin/uwsgi Python Version: 3.6.9 Python Path:
['/var/www', '.', '', '/var/www', '/home/aagam1/.virtualenvs/test/lib/python36.zip', '/home/aagam1/.virtualenvs/test/lib/python3.6', '/home/aagam1/.virtualenvs/test/lib/python3.6/lib-dynload', '/usr/lib/python3.6', '/home/aagam1/.virtualenvs/test/lib/python3.6/site-packages', '/home/aagam1/NotesSharing']

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.

.

Request Method: GET
Request URL:    http://shrif.pythonanywhere.com/
Django Version: 3.2.3
Exception Type: TemplateDoesNotExist
Exception Value:    
index.html
Exception Location: /usr/local/lib/python3.7/site-packages/django/template/loader.py, line 19, in get_template
Python Executable:  /usr/local/bin/uwsgi
Python Version: 3.7.10
Python Path:    
['/var/www',
 '.',
 '',
 '/var/www',
 '/usr/local/lib/python37.zip',
 '/usr/local/lib/python3.7',
 '/usr/local/lib/python3.7/lib-dynload',
 '/usr/local/lib/python3.7/site-packages',
 '/home/shrif/kagzi/']

Inside our computer code are work properly

Below the bit you pasted, in the error message, you should see something like:

Using engine django:

django.template.loaders.filesystem.Loader: /home/shrif/kagzi/templates/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django/contrib/admin/templates/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django/contrib/auth/templates/index.html (Source does not exist)

Make sure that you set up Django to look for the templates in the right places, and that the template index.html actually exists.

I have the same problem too!

TemplateDoesNotExist at /accounts/login/ registration/login_social.html Request Method: GET Request URL: https://noushin.pythonanywhere.com/accounts/login/ Django Version: 3.2.5 Exception Type: TemplateDoesNotExist Exception Value:
registration/login_social.html Exception Location: /home/noushin/.virtualenvs/django3/lib/python3.9/site-packages/django/template/loader.py, line 47, in select_template Python Executable: /usr/local/bin/uwsgi Python Version: 3.9.5 Python Path:
['/home/noushin/django_projects/mysite', '/var/www', '.', '', '/var/www', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/home/noushin/.virtualenvs/django3/lib/python3.9/site-packages']

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

mma_dashboard/layout2.html 1 {% extends "mma_dashboard/layout2.html" %} 2
3 {% block body %} 4 <div class="container-main-body"> 5 <h1>Projects</h1> 6 <ul> 7 {% for project in projects %} 8 <li> 9 <a href="{% url 'project' project.id %}"> 10 {{ project.name }} 11 </a>

Could it be problem with capital letters in filenames? Windows does not care about capitalization, Linux does.

That was it. I had a capital letter in one of my template html files. Thank you so much for the help!

Excellent, glad we could help!

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)

@king1982 it looks like your problem is the slash in 'learning_logs\index.xhtml', it needs to be a forward slash 'learning_logs/index.xhtml'

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.

How is it failing now? (did you reload your web app after making the change?)

Hi fjl, it is ok now i reloaded my web app everytime i have changed.

Glad to hear that it works for you!

TemplateDoesNotExist at / homepage.html Request Method: GET Request URL: http://sdavis.pythonanywhere.com/ Django Version: 3.2.18 Exception Type: TemplateDoesNotExist Exception Value:
homepage.html Exception Location: /home/SDavis/.virtualenvs/env/lib/python3.7/site-packages/django/template/loader.py, line 19, in get_template Python Executable: /usr/local/bin/uwsgi Python Version: 3.7.13 Python Path:
['/home/SDavis/pmportfolio', '/var/www', '.', '', '/var/www', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/home/SDavis/.virtualenvs/env/lib/python3.7/site-packages']

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.

What is the full path to homepage.html?

Just to add to that -- what do you have in your TEMPLATES variable in your settings?

.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['/home/SDavis/pmportfolio/portfoliowebsite/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',
            ],
        },
    },

==================================================================

Project name : portfoliowebsite

and the path to homepage.html is :

portfoliowebsite/templates/homepage.html

[edit by admin: formatting]

.

TemplateDoesNotExist at /
homepage.html
Request Method: GET
Request URL:    http://sdavis.pythonanywhere.com/
Django Version: 4.2
Exception Type: TemplateDoesNotExist
Exception Value:    
homepage.html
Exception Location: /home/SDavis/.virtualenvs/env/lib/python3.10/site-packages/django/template/loader.py, line 19, in get_template
Raised during:  portfolio.views.homepage
Python Executable:  /usr/local/bin/uwsgi
Python Version: 3.10.5
Python Path:    
['/home/SDavis/pmportfolio',
 '/var/www',
 '.',
 '',
 '/var/www',
 '/usr/local/lib/python310.zip',
 '/usr/local/lib/python3.10',
 '/usr/local/lib/python3.10/lib-dynload',
 '/home/SDavis/.virtualenvs/env/lib/python3.10/site-packages']
Server time:    Thu, 06 Apr 2023 13:22:46 +0000
Template-loader postmortem
Django tried loading these templates, in this order:

Using engine django:

django.template.loaders.filesystem.Loader: /home/SDavis/pmportfolio/portfoliowebsite/templates/homepage.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/SDavis/.virtualenvs/env/lib/python3.10/site-packages/django/contrib/admin/templates/homepage.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/SDavis/.virtualenvs/env/lib/python3.10/site-packages/django/contrib/auth/templates/homepage.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/SDavis/.virtualenvs/env/lib/python3.10/site-packages/bootstrap5/templates/homepage.html (Source does not exist)

================================================================================

This is the recent error after making the above posted changes.

[edit by admin: formatting]

Can we take a look at your files? We can see them from our admin interface, but we always ask for permission first.

Please do. You can look the files.

Thanks!

In your settings.py, you have this in your TEMPLATES (as per your code block above):

'/home/SDavis/pmportfolio/portfoliowebsite/templates'

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.

Let me try.

The site worked but the images in my static folder are not loading.

The error is sorted.. THANKS! The image in the homepage.html is sorted too..

Just one more thing .. do I need to set the DEBUG = False or should it remain True?

Glad to hear that! Regarding the DEBUG setting, it depends on your needs and state of the development, see the docs.

Thanks again. Will do.

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:

Using engine django:

django.template.loaders.filesystem.Loader: /home/Vke33/vikolee.github.io/index.html (Source does not exist)
django.template.loaders.filesystem.Loader: /home/Vke33/templates/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/Vke33/.virtualenvs/venv/lib/python3.9/site-packages/django/contrib/admin/templates/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/Vke33/.virtualenvs/venv/lib/python3.9/site-packages/django/contrib/auth/templates/index.html (Source does not exist)

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

Where exactly is the template file stored? How have you configured the template search path in your settings.py?

Sir, i'm also having the same issue. My templates are not being rendered despite giving the correct path as of my knowledge.I'm a newbie django developer. Please help me, i've been trying to deploy the app from quite a lot time now.

Where exactly is the template file stored? How have you configured the template search path in your settings.py?