Django Admin - change header #39;Django administration#39; text(Django Admin - 更改标题“Django 管理文本)
问题描述
如何更改 django 管理标头中的Django 管理"文本?
How does one change the 'Django administration' text in the django admin header?
自定义管理员"文档中似乎没有涵盖它.
It doesn't seem to be covered in the "Customizing the admin" documentation.
推荐答案
更新:如果您使用的是 Django 1.7+,请参阅 在下面回答.
Update: If you are using Django 1.7+, see the answer below.
2011 年的原始答案:您需要创建自己的管理 base_site.html 模板来执行此操作.最简单的方法是创建文件:
Original answer from 2011:
You need to create your own admin base_site.html template to do this. The easiest way is to create the file:
/<projectdir>/templates/admin/base_site.html
这应该是 原始 base_site.html,除了放入您的自定义标题:
This should be a copy of the original base_site.html, except putting in your custom title:
{% block branding %}
<h1 id="site-name">{% trans 'my cool admin console' %}</h1>
{% endblock %}
为此,您需要为您的项目设置正确的设置,即在 settings.py 中:
For this to work, you need to have the correct settings for your project, namely in settings.py:
- 确保将
/projectdir/templates/添加到TEMPLATE_DIRS. - 确保将
django.template.loaders.filesystem.Loader添加到TEMPLATE_LOADERS.
- Make sure
/projectdir/templates/is added intoTEMPLATE_DIRS. - Make sure
django.template.loaders.filesystem.Loaderis added intoTEMPLATE_LOADERS.
有关 settings.py 的更多信息,请参阅文档.
See docs for more information on settings.py.
这篇关于Django Admin - 更改标题“Django 管理"文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Django Admin - 更改标题“Django 管理"文本
基础教程推荐
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
