Hansong Li Hansong Li - 1 year ago 73
Python Question

django: instantiating AdminSite changes not reflected

I am trying to change the templates of admin site, and tried overriding by creating a local template for admin, but failed without knowing why: template way. So now I tried to create a instance of AdminSite and make changes from there, but still failed. I have:

urlpatterns = [
url(r'^myadmin/', admin.site.urls),

from django.contrib import admin
from .models import Equipment, Calibration, Flag, Tests
from django.contrib.admin import AdminSite

class MyAdminSite(AdminSite):
site_header = "Equipment Calibration Database"
site_title = "Equipment Calibration Database"
index_title = "Equipment Calibration Database"
# Register your models here.
admin_site = MyAdminSite(name = 'myadmin')


Now when I go to, I still find that none of the text I specified in MyAdminSite is in effect, I still see "Django administration" and "Site administration".

This is all acting really weird and helps are greatly welcome

Answer Source

To change the text in the admin, all you need to add to the admin.py is as follows:

admin.site.site_header = "Equipment Calibration Database"
admin.site.site_title = "Equipment Calibration Database"
admin.site.index_title = "Equipment Calibration Database"