Question

I get this error:

TemplateDoesNotExist at /link/

link_app/link_list.html
Request Method: GET
Request URL:    http://127.0.0.1:8000/link/
Django Version: 1.6
Exception Type: TemplateDoesNotExist
Exception Value:    
link_app/link_list.html

Inside my link_app, I have a templates folder in which I have placed link_list.html

I have also included the following in my setting.py

TEMPLATE_LOADERS = (
   'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

I also have a templates folder that is common to project (not to app) for which I have

TEMPLATE_DIRS=(os.path.join(BASE_DIR, 'templates'),) in the settings.py

EDIT: from the error, it seems to look for list_html at link_app/link_list.html

but it must be looking at link_app/templates/link_list.html

Project-Structure:

LinkDjangoProject
     link_project
     link_app
          templates
             link_list.html
     templates
     manage.py
Was it helpful?

Solution

The standard project structure (partial) is this:

projectname
  |
  |-projectname  <-- settings.py, etc.
  |
  |-someapp
    |
    |-templates
      |
      |-someapp  <-- templates that are referenced with "someapp/a_template.html" go inside this directory
      |
      ...

I suspect you are missing the someapp directory inside your projectname/someapp/templates directory.


This structure allows templates from one app to be overridden in another app, provided the overriding app is placed before the original app in the INSTALED_APPS list in settings.py

Similar directory structure is used with static and/or media files as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top