1

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:

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

admin.py
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')

admin.site.register(Equipment)
admin.site.register(Calibration)
admin.site.register(Flag)
admin.site.register(Tests)

Now when I go to http://127.0.0.1:8000/myadmin/, 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

Community
  • 1
  • 1
Hansong Li
  • 417
  • 2
  • 11
  • 26

1 Answers1

1

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"
Hybrid
  • 6,741
  • 3
  • 25
  • 45
  • Thanks this worked! Do you know why the template way I did in http://stackoverflow.com/questions/39132187/django-how-do-i-actually-override-admin-site-template?noredirect=1#comment65613565_39132187 doesn't work by any chance? – Hansong Li Aug 25 '16 at 19:59
  • I'm guessing because the way you did it was for an older version of Django, they made it simpler recently (the code I posted above) – Hybrid Aug 25 '16 at 20:43