Django template path settings: templates, TEMPLATE_DIRS, TEMPLATES,
Django version: 1.9.5
First, set templates to the same directory as manage. py, and then the template file under templates.
Then set settings. py: Pay attention to the modification of the yellow area.
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, you can directly search for templates in the APP directory. This is the default setting. Therefore, you can simply put the templates folder under the app.
'App _ dirs': False. If it is set to False, it will not be searched in the APP, but will be searched based on the path in DIRS.
The above two methods are successfully tested!
It may be due to version issues. The previous version should have a parameter:
TEMPLATE_DIRS = (OS. path. join (BASE_DIR, ''templates'). replace ('\', '/'),) settings
This method was not successfully tested in 1.9.5.
Django version updates will indeed bring a lot of learning costs.