Reputation: 1236
I am trying to override Django's default template. For now just the base_site.html. I'm trying to change the text django administration.
I did the following:
/opt/mydjangoapp/templates/admin
base_site.html
, so that I have the title 'My App Admin' as opposed to 'Django Administration'My settings file looks as follows:
INSTALLED_APPS = (
'mydjangoapp',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
)
...
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['/opt/mydjangoapp/templates/'],
'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',
],
'debug':True,
'loaders': (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader'
),
},
},
]
But unfortunately, Django version 1.8 seems to be ignoring my template changes and loading the original template files. Any suggestions as to how I can override the original layout for the admin. Bare in mind changing the title is just the beginning of the changes that I want to perform?
Upvotes: 2
Views: 3167
Reputation: 77251
First, make sure your application is listed first, because Django always take the resources from the first application where it finds them, according to the order in settings.INSTALLED_APPS
.
In this case the app was listed first, but the override was not working because the templates were placed under the global template directories listed under settings.TEMPLATES['DIRS']
which are not tied to any particular app and will have the least priority.
If this is your case, you must move the template folder inside your app (for example, /opt/mydjangoapp/mydjangoapp/templates/
instead of /opt/mydjangoapp/templates/
) and wipe the reference at settings.TEMPLATES['DIRS']
.
Upvotes: 3