Django Admin - change header 'Django administration' text Django Admin - change header 'Django administration' text python python

Django Admin - change header 'Django administration' text


As of Django 1.7 you don't need to override templates. You can now implement site_header, site_title, and index_title attributes on a custom AdminSite in order to easily change the admin site’s page title and header text. Create an AdminSite subclass and hook your instance into your URLconf:

admin.py:

from django.contrib.admin import AdminSitefrom django.utils.translation import ugettext_lazyclass MyAdminSite(AdminSite):    # Text to put at the end of each page's <title>.    site_title = ugettext_lazy('My site admin')    # Text to put in each page's <h1> (and above login form).    site_header = ugettext_lazy('My administration')    # Text to put at the top of the admin index page.    index_title = ugettext_lazy('Site administration')admin_site = MyAdminSite()

urls.py:

from django.conf.urls import patterns, includefrom myproject.admin import admin_siteurlpatterns = patterns('',    (r'^myadmin/', include(admin_site.urls)),)

Update: As pointed out by oxfn you can simply set the site_header in your urls.py or admin.py directly without subclassing AdminSite:

admin.site.site_header = 'My administration'


There is an easy way to set admin site header - assign it to current admin instance in urls.py like this

admin.site.site_header = 'My admin'

Or one can implement some header-building magic in separate method

admin.site.site_header = get_admin_header()

Thus, in simple cases there's no need to subclass AdminSite


Update: If you are using Django 1.7+, see the answer below.


Original answer from 2011:You need to create your own admin base_site.html template to do this. The easiest way is to create the file:

/<projectdir>/templates/admin/base_site.html

This should be a copy of the original base_site.html, except putting in your custom title:

{% block branding %}<h1 id="site-name">{% trans 'my cool admin console' %}</h1>{% endblock %}

For this to work, you need to have the correct settings for your project, namely in settings.py:

  • Make sure /projectdir/templates/ is added into TEMPLATE_DIRS.
  • Make sure django.template.loaders.filesystem.Loader is added into TEMPLATE_LOADERS.

See docs for more information on settings.py.