50
In current Django (1.10) TEMPLATE_DIRS is deprecated, so:
- Add a
templates
directory at the project root, -
In settings.py find TEMPLATES -> DIRS and add it like this:
TEMPLATES = [ { ... 'DIRS': [(os.path.join(BASE_DIR, 'templates')),], ... }
-
Add a base.html to that directory.
- Extend it wherever you want using
{% extends 'base.html' %}
8
- Add a
templates
directory at the project root, and add it to yourTEMPLATE_DIRS
setting. - Add a base.html to that directory.
- Extend it wherever you want using
{% extends 'base.html' %}
- [Django]-Change list display link in django admin
- [Django]-How to automatically reload Django when files change?
- [Django]-What's the difference between `from django.conf import settings` and `import settings` in a Django project
3
For Django versions above 1.8 the upgrade doc suggests the vanilla settings (for most non-advanced django tangoers like me) be added to your settings.py:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [(os.path.join(BASE_DIR, 'my_Templates_Directory')),],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
# list if you haven't customized them:
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Both BACKEND and OPTIONS were required, otherwise I had errors relating to ‘INVALID BACKEND’ and ‘django.contrib.auth.context_processors.auth’ must be in TEMPLATES’.
- [Django]-How to generate urls in django
- [Django]-ValueError: Cannot add *: instance is on database "default", value is on database "None"
- [Django]-How to use Django 1.8.5 ORM without creating a django project?
Source:stackexchange.com