How does one change the \'Django administration\' text in the django admin header?
It doesn\'t seem to be covered in the \"Customizing the admin\" documentation.
You just override the admin/base_site.html
template (copy the template from django.contrib.admin.templates
and put in your own admin template dir) and replace the branding
block.
You can use these following lines in your main urls.py
you can add the text in the quotes to be displayed
To replace the text Django admin use admin.site.site_header = ""
To replace the text Site Administration use admin.site.site_title = ""
To replace the site name you can use admin.site.index_title = ""
To replace the url of the view site button you can use admin.site.site_url = ""
In urls.py
you can override the 3 most important variables:
from django.contrib import admin
admin.site.site_header = 'My project' # default: "Django Administration"
admin.site.index_title = 'Features area' # default: "Site administration"
admin.site.site_title = 'HTML title from adminsitration' # default: "Django site admin"
Reference: Django documentation on these attributes.
Just go to admin.py file and add this line in the file :
admin.site.site_header = "My Administration"
As you can see in the templates, the text is delivered via the localization framework (note the use of the trans
template tag). You can make changes to the translation files to override the text without making your own copy of the templates.
mkdir locale
./manage.py makemessages
Edit locale/en/LC_MESSAGES/django.po
, adding these lines:
msgid "Django site admin"
msgstr "MySite site admin"
msgid "Django administration"
msgstr "MySite administration"
./manage.py compilemessages
See https://docs.djangoproject.com/en/1.3/topics/i18n/localization/#message-files
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 AdminSite
from django.utils.translation import ugettext_lazy
class 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, include
from myproject.admin import admin_site
urlpatterns = 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'