Django Version: 1.9.5
First set the templates in the same directory as manage.py, and then templates under the template file.
Then set settings.py: Notice to change the yellow place.
TEMPLATES = [ { ' backend ': ' django.template.backends.django.DjangoTemplates ', ' DIRS ': [ Os.path.join (Base_dir, ' Templates '). replace (' \ \ ', '/'),], # ' app_dirs ': True, ' app_dirs ': False, ' 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 ', ], }, },]
If ' app_dirs ': True, look for templates directly in the app's directory, this is the default setting, so the simplest is to put the Templates folder directly under the app.
' App_dirs ': false, set to false, will not go to the APP to find, but based on the path in the DIRS to find.
The above two methods of testing success!
This may be due to a version issue, the previous version should have a parameter:
( os. Path. Join(base_dir, 'templates '). Replace('\ \'/'),set
This method was not tested successfully in 1.9.5.
The Django version update does bring a lot of cost to learning.
Django Template path settings: templates,template_dirs,templates