We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
If you want to override the site header and site title in your Django admin, most people start with overriding the admin templates. Even though that's a perfectly fine approach, I prefer to do it differently.
I first start with creating a subclass of admin.AdminSite
:
mysite/admin.py
from django.contrib import admin
class YellowDuckAdminSite(admin.AdminSite):
site_header = "YellowDuck.be"
site_title = "YellowDuck.be"
Then, you need to use it as the default_site
for your AdminConfig
subclass:
mysite/apps.py
from django.contrib.admin.apps import AdminConfig
class YellowDuckAdminConfig(AdminConfig):
default_site = 'mysite.admin.YellowDuckAdminSite'
As the last step, you need to replace django.contrib.admin
with your admin config class:
mysite/settings.py
INSTALLED_APPS = [
...
'mysite.apps.YellowDuckAdminConfig', # replaces django.contrib.admin
...
]
You can find more info in the documentation about this approach.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.