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.
From Django 2.0 you can just add a single line in the url.py
and change the name.
# url.py
from django.contrib import admin
admin.site.site_header = "My Admin Central" # Add this
For older versions of Django. (<1.11 and earlier) you need to edit admin/base_site.html
Change this line
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
to
{% block title %}{{ title }} | {{ site_title|default:_('Your Site name Admin Central') }}{% endblock %}
You can check your django
version by
django-admin --version
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
The easiest way of doing it make sure you have
from django.contrib import admin
and then just add these at bottom of url.py
of you main application
admin.site.site_title = "Your App Title"
admin.site.site_header = "Your App Admin"
admin.py:
from django.contrib.admin import AdminSite
AdminSite.site_title = ugettext_lazy('My Admin')
AdminSite.site_header = ugettext_lazy('My Administration')
AdminSite.index_title = ugettext_lazy('DATA BASE ADMINISTRATION')
You can use AdminSite.site_header
to change that text. Here is the docs
There are two methods to do this:
1] By overriding base_site.html
in django/contrib/admin/templates/admin/base_site.html
:
Following is the content of base_site.html
:
{% extends "admin/base.html" %}
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1>
{% endblock %}
{% block nav-global %}{% endblock %}
Edit the site_title & site_header in the above code snippet. This method works but it is not recommendable since its a static change.
2] By adding following lines in urls.py
of project's directory:
admin.site.site_header = "AppHeader"
admin.site.site_title = "AppTitle"
admin.site.index_title = "IndexTitle"
admin.site.site_url = "Url for view site button"
This method is recommended one since we can change the site-header, site-title & index-title without editing base_site.html
.