12

I'm studying Django. I saw django tutorial part7 and I wanted to rename the name of the django admin page. So, I did it but it hasn't worked.....

mysite/mysite/settings.py:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

mysite/templates/admin/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:_('mysite') }}</a></h1>
{% endblock %}

{% block nav-global %}{% endblock %}

I renamed to mysite from Django administration.

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129

3 Answers3

26

You need to do

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">Mysite</a></h1>
{% endblock %}

Better way

Simply go to urls.py of your project and add this outside urlpatterns.

admin.site.site_header = 'My Site Admin Panel'
admin.site.site_title = 'My Site Title'

make sure, below line is included at top.

from django.contrib import admin
Astik Anand
  • 12,757
  • 9
  • 41
  • 51
23

Use this part of code in your admin.py:

from django.contrib import admin

admin.site.site_title = "<your_title>"
admin.site.site_header = "<your_header>"
admin.site.index_title = "<your_index_title>"
Vladyslav Moisieienkov
  • 4,118
  • 4
  • 25
  • 32
0

You can change site title, site header and index title in Django Admin as shown below. *You can see my answer explaining it in detail:

# "admin.py"

from django.contrib import admin

admin.site.site_title = 'My site title'
admin.site.site_header = 'My site header'
admin.site.index_title = 'My index title'
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129