Daniel Casserly
Daniel Casserly

Reputation: 3500

Trouble overriding the Django Admin template files

I have seen this question answered but I can't get it to work on my site. I have installed a site using Django 1.8 as I wanted to use the django-admin-bootstrapped plugin. I am also using the template provided by Heroku.

What I would like to do is override at the very least the base_site.html to change the site title and page title. However, I have tried several locations for this file including the following:

PROJECT ROOT
  |--templates
     |--admin
        |--base_site.html


PROJECT ROOT
  |--templates
     |--admin
        |--<appname>
           |--base_site.html

PROJECT ROOT
  |--<appname>
     |--templates
        |--admin
           |--base_site.html

PROJECT ROOT
  |--<appname>
     |--templates
        |--admin
          |--<appname>
             |--base_site.html

None of which work. I have the following in my settings.py

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, 'templates')],
    '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',
        ],
        'debug': DEBUG,
    },
},
]

I am just wondering if I am doing something fundamentally wrong or if I just haven't found the magic location for the templates folder (or order of folders etc).

On a related note, is there anyway of debugging where the templates are being pulled from or is it just guesswork based on where they are supposed to be coming from?

Upvotes: 0

Views: 562

Answers (1)

Anna
Anna

Reputation: 553

Not every template in contrib/admin/templates/admin may be overridden per app or per model. The following can:

  • app_index.html
  • change_form.html
  • change_list.html
  • delete_confirmation.html
  • object_history.html

enter link description here

Override change_list.html to change the site title and page title

Upvotes: 0

Related Questions