How to change the database name display in django admin site?

Question:

Is it possible to change change the database name in django admin site?

Just like how I change the following:

admin.site.site_header = "Administrator"

admin.site.site_title = "Administrator"

admin.site.index_title = "Admin"

enter image description here

Asked By: Claire Ann Vargas

||

Answers:

There are two options, you can do it manually, or you can do it through the help of an external python library

Manually

is by creating custom AdminSite

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'^admin/', include(admin_site.urls)),
)

by using python package

you can use the python package called django-admin-interface

pip install django-admin-interface

you’ll need to import it into your settings.py

INSTALLED_APPS = (
    #...
    "admin_interface",
    "flat_responsive", # only if django version < 2.0
    "flat", # only if django version < 1.9
    "colorfield",
    #...
    "django.contrib.admin",
    #...
)

# only if django version >= 3.0
X_FRAME_OPTIONS = "SAMEORIGIN"
SILENCED_SYSTEM_CHECKS = ["security.W019"]

after installing it, you’ll be able to customize your admin panel from the themes menu inside your admin panel

enter image description here


You can change the app name by adding verbose_name under app.py

from django.apps import AppConfig

class PharmacyConfig(AppConfig):
    name = 'pharmacy'
    verbose_name = 'Your Home Page'
Answered By: MrKioZ
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.