Django : TemplateDoesNotExist at /.../
You have forgotten the first argument request
when you call render
.
return render(request, 'index.html', context)
You can have multiple template directories, e.g. src/template
and pages/template
. If you want to have a src/template
directory, then you need to include it in your DIRS
option`.
'DIRS': [os.path.join(BASE_DIR, 'templates')],
You don't need pages/templates
in the DIRS
directory -- templates in that directory will be found by the app loader because you have APP_DIRS
set to True
, and pages
is in your INSTALLED_APPS
setting.
You probably forgot to add your app in Installed_Apps setting.
INSTALLED_APPS = [
...
'your_app'
]
You have wrong route of your templates. By default django have the folder "template" for html files, try create folder called template inside your app folder and inside them the file index.html