My site hosted properly in PythonAnywhere for a while and after when I tried to access it threw a TemplateDoesNotExist error even though it was running properly and I haven't made any extra additions to the code. What is the problem??
My site hosted properly in PythonAnywhere for a while and after when I tried to access it threw a TemplateDoesNotExist error even though it was running properly and I haven't made any extra additions to the code. What is the problem??
Does template exist in the place your web app is looking for it? Maybe it exists in some other place.
No I haven't changed anything in the directory structure at all.It was running fine till the error came at one point. I'll add some code for clarity
This is the part of the views.py where the error occurs
def button(request):
return render(request,'home/CSR15/templates/home.html',{})
This is my directory structure:
/home/CSR15/.... project_name/
templates/home.html
I clearly have the templates folder where it is and that is the only file I have in there. I also have it properly mentioned in my settings.py :
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['home/CSR15/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',
],
},
},
]
I didn't change anything(even the settings.py was unchanged) but it threw this error from the error log Clipped it a little
2020-02-28 07:15:58,642: Internal Server Error: / Traceback (most recent call last): File "/home/CSR15/Know-ur-level/buttonpython/buttonpython/views.py", line 11, in button return render(request,'home/CSR15/templates/home.html',{}) django.template.exceptions.TemplateDoesNotExist: home/CSR15/templates/home.html
So at this point I am fully and thoroughly confused at what's going on
absolute path has to start with / so /home and so on
Yeah it works now. I guess I must have removed it at one point somwhere