Forums

template does not excist

Hello, I am trying to host my Django app which is working on local host, but when i try to load it by pythonanywhere the error ( template does not excist ) occurs. I have read some articles en tried to chanced the templates folder in settings.py, but it wont work.

I am looking for a button to upload my code , but can`t find it.

Make sure that you actually have the template that Django is complaining about in one of the templates directories in your Django project directory.

There is an "Upload a file" button at the bottom of every directory listing on the Files tab.

Hello,

This the message i keep getting, no matter what i put in settings DIR:

TemplateDoesNotExist at / jobs\home.html Request Method: GET Request URL: http://bossie.pythonanywhere.com/ Django Version: 2.2.5 Exception Type: TemplateDoesNotExist Exception Value: jobs\home.html Exception Location: /home/Bossie/.virtualenvs/django2.1/lib/python3.7/site-packages/django/template/loader.py in get_template, line 19 Python Executable: /usr/local/bin/uwsgi Python Version: 3.7.0 Python Path: ['/var/www', '.', '', '/var/www', '/home/Bossie/.virtualenvs/django2.1/lib/python37.zip', '/home/Bossie/.virtualenvs/django2.1/lib/python3.7', '/home/Bossie/.virtualenvs/django2.1/lib/python3.7/lib-dynload', '/usr/lib/python3.7', '/home/Bossie/.virtualenvs/django2.1/lib/python3.7/site-packages', '/home/Bossie/portfolio-project'] Server time: Thu, 7 Nov 2019 19:11:41 +0000 Template-loader postmortem Django tried loading these templates, in this order: Using engine django: django.template.loaders.filesystem.Loader: /home/Bossie/portfolio-project/templates/jobs\home.html (Source does not exist) django.template.loaders.app_directories.Loader: /home/Bossie/portfolio-project/blog/templates/jobs\home.html (Source does not exist) django.template.loaders.app_directories.Loader: /home/Bossie/portfolio-project/jobs/templates/jobs\home.html (Source does not exist) django.template.loaders.app_directories.Loader: /home/Bossie/.virtualenvs/django2.1/lib/python3.7/site-packages/django/contrib/admin/templates/jobs\home.html (Source does not exist) django.template.loaders.app_directories.Loader: /home/Bossie/.virtualenvs/django2.1/lib/python3.7/site-packages/django/contrib/auth/templates/jobs\home.html (Source does not exist)

This is my settings.py

ROOT_URLCONF = 'portfolio.urls'

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

It looks like you have windows \ instead of linux / in your path.

How can I chance the slash to the path? I am pretty new here. Thank you

It will be in your code somewhere -- probably in one of the views.py files.

Hello, i have changed the slash , but now it gives this servererror.

OperationalError at / could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? Request Method: GET Request URL: http://bossie.pythonanywhere.com/ Django Version: 2.2.5 Exception Type: OperationalError Exception Value:
could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? Exception Location: /home/Bossie/.virtualenvs/django2.1/lib/python3.7/site-packages/psycopg2/init.py in connect, line 126 Python Executable: /usr/local/bin/uwsgi Python Version: 3.7.0 Python Path:
['/var/www', '.', '', '/var/www', '/home/Bossie/.virtualenvs/django2.1/lib/python37.zip', '/home/Bossie/.virtualenvs/django2.1/lib/python3.7', '/home/Bossie/.virtualenvs/django2.1/lib/python3.7/lib-dynload', '/usr/lib/python3.7', '/home/Bossie/.virtualenvs/django2.1/lib/python3.7/site-packages', '/home/Bossie/portfolio-project'] Server time: Tue, 12 Nov 2019 11:01:38 +0000

It looks like you're trying to connect to a Postgres database that does not exist. It will not work on PythonAnywhere, because you have a free account, so you cannot connect out of PythonAnywhere and, also since you have a free account, you do not have a Postgres database within PythonAnywhere.

Okay, So the the option are, get a payment account or try another hosting website. Thanks

Or don't use a Postgres database. We provide MySQL databases with free accounts.