django:实例化AdminSite更改未反映

时间:2016-08-25 19:05:55

标签: python django django-admin

我正在尝试更改管理网站的模板,并尝试通过为管理员创建本地模板来覆盖,但在不知道原因的情况下失败:template way。所以现在我尝试创建一个AdminSite实例并从那里进行更改,但仍然失败了。我有:

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)

现在当我去http://127.0.0.1:8000/myadmin/时,我仍然发现我在MyAdminSite中指定的文字都没有生效,我仍然看到" Django管理"和#34;网站管理"。

这一切都非常奇怪,非常受欢迎

1 个答案:

答案 0 :(得分:1)

要更改管理员中的文字,您需要添加到admin.py的内容如下:

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