Templates are set in the settings.py
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
'/var/www/rsa/html', #1) this sets a static path
os.path.join( PROJECT_PATH, 'templates').replace('\\','/'), #2) this sets a dynamic path
],
'APP_DIRS': True,
'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',
],
},
},
]
the first 1) path
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
just says all templates are available at this absolute path. not really recommended. I prefer the second option that sets templates as per app.
os.path.join( PROJECT_PATH, 'templates').replace('\\','/'),
just means that whatever apps you make using
./manage startapp app_name
inside that app folder, you can create a folder called "templates" and put whatever templates you want in there.
extend templates in the static folders, & have app-specific templates in the dynamic folder.
in an app called countries
you can have a template in
/countries/templates/display.html
inside you can have
{% extends 'template/app.html' %} << this file is located in the static folder
{% block 'content' %}
content goes here
{% endblock %}
Hope that helps.
p.s. templates are searched for in order they are listed so first the static then the dynamic location is looked at.
if app.html is found in templates then django will stop there and wont look any further.