gpt4 book ai didi

python - 为 Django 管理员扩展 base_site.html

转载 作者:太空宇宙 更新时间:2023-11-03 11:53:03 26 4
gpt4 key购买 nike

我正在使用 Django Suit在我的项目中。Django 套装带有默认页脚,我想更改或删除它。根据文档上的说明:

You must extend base_site.html template to customize footer links, copyright text or to add extra JS/CSS files. Example file is available on github.

将自定义的 base_site.html 模板文件复制到项目的主目录 application template/admin/目录并取消注释和编辑 您想要扩展的 block 。

但是当我这样做时,每当我取消注释其中一个 block 时,我都会遇到以下错误:

Exception Type: TemplateSyntaxError

Exception Value:Could not parse the remainder: '% block footer_links %' from '% block footer_links %'

知道为什么会发生这种情况吗?我该如何解决?

base_site.html:

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

{# Additional <head> content here, some extra meta tags or favicon #}
{#{% block extrahead %}#}
{#{% endblock %}#}


{# Additional CSS includes #}
{#{% block extrastyle %}#}
{# <link rel="stylesheet" type="text/css" href="{% static 'css/my_project.css' %}" media="all">#}
{#{% endblock %}#}


{# Additional JS files in footer, right before </body> #}
{#{% block extrajs %}#}
{# <script type="text/javascript" src="{% static 'js/my_project.js' %}"></script>#}
{#{% endblock %}#}


{ Footer links (left side) }
{{% block footer_links %}}
{{% endblock %}}

{# Additional header content like notifications or language switcher #}
{#{% block header_content %}#}
{# {{ block.super }}#}
{# <div class="header-content">#}
{# <!-- First icon column -->#}
{# <div class="header-column icon">#}
{# <i class="icon-home"></i><br>#}
{# <i class="icon-cog"></i>#}
{# </div>#}
{# <div class="header-column" style="margin-right: 20px">#}
{# <a href="/" class="grey">Front-end</a><br>#}
{# <a href="" class="grey">One more link</a>#}
{# </div>#}
{# <!-- Second icon column -->#}
{# <div class="header-column icon">#}
{# <i class="icon-comment"></i>#}
{# </div>#}
{# <div class="header-column">#}
{# <a href="" class="grey">5 new messages</a>#}
{# </div>#}
{# </div>#}
{#{% endblock %}#}

{ Footer branding name (center) }
{{% block footer_branding %}}
{{% endblock %}}


{ Footer copyright (right side) }
{{% block copyright %}}
{ Copyright &copy; 2013 Client<br>Developed by <a href="http://yoursite.com" target="_blank">YourName</a> }
{{% endblock %}}

最佳答案

您弄错了 Django 模板的语法。以下是取消注释文件页 footer 分的正确方法:

{# Footer copyright (right side) #}
{% block copyright %}
Copyright &copy; 2013 Client<br>Developed by <a href="http://yoursite.com" target="_blank">YourName</a>
{% endblock %}

由于整个文件中都存在这些错误,请使用新副本 base_site.html

关于python - 为 Django 管理员扩展 base_site.html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21162535/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com