0
0
DjangoHow-ToBeginner · 3 min read

How to Customize Admin Site Title in Django

To customize the admin site title in Django, set the site_header attribute of admin.site in your admin.py file. For example, use admin.site.site_header = 'My Custom Admin' to change the title shown on the admin pages.
📐

Syntax

Use the site_header attribute of the admin.site object to set a custom title for the Django admin site. This changes the text shown in the top-left corner of the admin interface.

  • admin.site.site_header: The main title text on the admin site.
python
from django.contrib import admin

admin.site.site_header = 'Your Custom Admin Title'
💻

Example

This example shows how to set a custom admin site title by modifying admin.py in your Django app. The admin header will display "My Project Admin" instead of the default "Django Administration".

python
from django.contrib import admin

# Set a custom title for the admin site
admin.site.site_header = 'My Project Admin'

# Register your models below as usual
# from .models import MyModel
# admin.site.register(MyModel)
Output
The Django admin site header changes from "Django Administration" to "My Project Admin" on all admin pages.
⚠️

Common Pitfalls

Common mistakes when customizing the admin site title include:

  • Setting site_header in the wrong file or outside admin.py, so it does not take effect.
  • Forgetting to restart the Django development server after changes.
  • Confusing site_header with site_title or index_title, which control different parts of the admin UI.

Make sure to place the customization code in your app's admin.py and restart the server.

python
from django.contrib import admin

# Wrong: setting site_header in views.py or models.py will not work

# Correct usage in admin.py
admin.site.site_header = 'Correct Admin Title'
📊

Quick Reference

Here are the main attributes to customize Django admin site text:

AttributeDescriptionExample Value
site_headerText shown as the main admin site titleMy Custom Admin
site_titleText shown in the browser tab titleAdmin Portal
index_titleText shown on the admin index pageWelcome to Admin

Key Takeaways

Set admin.site.site_header in admin.py to change the admin site title.
Restart the Django server after making changes to see updates.
Use site_title and index_title to customize other admin UI texts.
Place customization code only in admin.py for it to work properly.