django.template.exceptions.TemplateDoesNotExist: AlgoDash/index.html

Posted by Poster under Error and Solution on 11/22/2021 | Points: 10 | Views : 803 | Status : [Member] | Replies : 0

I was getting above error in dJango and struggled for more than an hour to fix it. Its very frustrating and confusing

Solution


Keep the templates folder under the root of the project where manage.py exists. So the html file should be in this case templates/AlgoDash/index.html

Change the DIRS value under TEMPLATES in settings.py like below



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


And your project will work!




Responses

(No response found.)

Login to post response