无法更改Django管理模板 [英] Can't change Django admin template

查看:147
本文介绍了无法更改Django管理模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚开始官方Django教程已经遇到问题,无法在管理面板中更改页面名称。我试图用教程中建议的 base_site.html 中的自定义项替换一个默认的 Django管理我从django源目录复制到我的应用程序中的一个文件,试图将其移入/输出投票目录等),

我已经在设置中添加了 TEMPLATE_DIRS = [os。 path.join(BASE_DIR,'templates')] 已安装的应用程序'polls',但没有改变。

just started an official Django tutorial and already ran into a problem, can't change page name in admin panel. I'm trying to replace a default Django administration with something custom in the base_site.html as suggested in the tutorial (a file which I copied from the django source directory into my app, tried to move it in/out polls directory etc.),
I have added in settings TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')], and in installed apps also 'polls', but nothing changes.

任何建议,我可以做什么,以使其工作?

Any suggestions what I can do in order to make it work?

谢谢

推荐答案

如果您只更改这样的括号内的值,则不起作用

It will not work if you only change the value inside the parentheses like this

{{ site_header|default:_('Your custom name') }}

你需要做的是你必须用你想要的名字替换所有的这些。

What you need to do is you must replace all of the above with your desired name like this.

{% extends "admin/base.html" %}

{% block title %}{{ title }} | YOUR CUSTOM NAME{% endblock %}

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">YOUR CUSTOM NAME</a></h1>
{% endblock %}

{% block nav-global %}{% endblock %}

这篇关于无法更改Django管理模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆