Customising the Admin Template
Learn about the basics of adding a custom template to your Django admin page.
We'll cover the following...
Customising admin templates
To override or replace Django admin templates, you first need to configure your project to tell Django where to find your custom templates. To do so, you need to define the path in the DIRS
option of the TEMPLATES
parameter, which is located in helloworld/settings.py
.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
BASE_DIR,
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',
],
},
},
]
templates` as specified as a directory name, so you need to create this directory in your project as well.
You have created the necessary directory tree using the following commands:
mkdir sample_app/templates
mkdir sample_app/templates/admin
mkdir sample_app/templates/admin/sample_app
...