template does not exist django

Solutions on MaxInterview for template does not exist django by the best coders in the world

showing results for - "template does not exist django"
Nichole
19 Apr 2020
1First solution:
2
3These settings
4
5TEMPLATE_DIRS = (
6    os.path.join(SETTINGS_PATH, 'templates'),
7)
8mean that Django will look at the templates from templates/ directory under your project.
9
10Assuming your Django project is located at /usr/lib/python2.5/site-packages/projectname/ then with your settings django will look for the templates under /usr/lib/python2.5/site-packages/projectname/templates/
11
12So in that case we want to move our templates to be structured like this:
13
14/usr/lib/python2.5/site-packages/projectname/templates/template1.html
15/usr/lib/python2.5/site-packages/projectname/templates/template2.html
16/usr/lib/python2.5/site-packages/projectname/templates/template3.html
17Second solution:
18
19If that still doesn't work and assuming that you have the apps configured in settings.py like this:
20
21INSTALLED_APPS = (
22    'appname1',
23    'appname2',
24    'appname3',
25)
26By default Django will load the templates under templates/ directory under every installed apps. So with your directory structure, we want to move our templates to be like this:
27
28/usr/lib/python2.5/site-packages/projectname/appname1/templates/template1.html
29/usr/lib/python2.5/site-packages/projectname/appname2/templates/template2.html
30/usr/lib/python2.5/site-packages/projectname/appname3/templates/template3.html
31SETTINGS_PATH may not be defined by default. In which case, you will want to define it (in settings.py):
32
33import os
34SETTINGS_PATH = os.path.dirname(os.path.dirname(__file__))