I'm getting TemplateDoesNotExist at /task/
error.
This is my folder structure for project:
This is my taskmate/urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('task/',include('todolist_app.urls')),
path('todolist/',include('todolist_app.urls')),
]
This is my todolist_app/urls.py:
from django.urls import path
#from todolist_app import views
from . import views
urlpatterns = [
path('', views.todolist, name='todolist'),
]
This is my todolist_app/views.py:
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def todolist(request):
return render(request, 'todolist.html',{})
This is my settings.py(important components)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [(os.path.join(os.path.dirname(os.path.dirname(__file__)),'todolist_app/templates').replace('\\','/'))],#'DIRS':
'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'm highly suspicious that the issue I'm getting is due to "DIRS" of template. I have tried couple of different things there, but none seem to have worked.
These are what I've tried there:
'DIRS': [os.path.join(BASE_DIR,'templates')],
'DIRS': [os.path.join(os.path.dirname(__file__),'templates').replace('\\','/')],#'DIRS':
'DIRS': [(os.path.join(os.path.dirname(os.path.dirname(__file__)),'todolist_app/templates').replace('\\','/'))],#'DIRS':
I've also added "todolist_app" to installed apps.