如何更改Django admin头中的“Django administration”文本?

“自定义管理”文档中似乎没有涉及到这一点。


当前回答

基于这个问题的答案,在Django 1.8.3中给出了一个简单完整的解决方案。

在settings.py中添加:

ADMIN_SITE_HEADER = "My shiny new administration"

在urls.py中添加:

from django.conf import settings
admin.site.site_header = settings.ADMIN_SITE_HEADER

其他回答

对于Django 2.1.1,在urls.py中添加以下行

from django.contrib import admin

# Admin Site Config
admin.sites.AdminSite.site_header = 'My site admin header'
admin.sites.AdminSite.site_title = 'My site admin title'
admin.sites.AdminSite.index_title = 'My site admin index'

一个简单的方法是在项目文件夹中的urls.py文件中包含以下代码。

 in urls.py add 

  admin.site.site_header  =  "Site Header here"  
  admin.site.site_title  =  "Side title"
  admin.site.index_title  =  "Index title"

例如:

from django.contrib import admin
from django.urls import path
from django.conf.urls import include
from django.conf.urls.static import static
from django.conf import settings


admin.site.site_header  =  "Hadramawt Kitchen"  
admin.site.site_title  =  "Hadramawt Kitchen"
admin.site.index_title  =  "Hadramawt Admin"

urlpatterns = [
  path('admin/', admin.site.urls),
  path('', include('food_products.urls' )),
  path('categories', include('categories.urls' )),
  path('news', include('news.urls')),
  path('weeklyOffer', include('weekly_offer.urls'))
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

你只需要覆盖admin/base_site.html模板(从django.contrib.admin.templates中复制模板并放入你自己的管理模板dir中)并替换branding块。

简单方法是在url.py中添加以下代码

    urlpatterns = [
    #Your URLS here
    path('admin/', admin.site.urls),
]

admin.site.site_header = 'SiteName Admin'
admin.site.site_title  = 'SiteName'
admin.site.index_title   = 'Admin'

只需转到admin.py文件,并在文件中添加这一行:

admin.site。site_header = "我的政府"