Customising the Admin Template
Explore how to customize Django admin templates by setting the templates directory, overriding global and model-specific templates, and adding personalized content. Understand directory structures and learn how to make changes visible in the admin interface for improved design customization.
We'll cover the following...
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
...