为 Django 管理扩展 base_site.html

Yoa*_*rtz 5 python django django-templates django-suit

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

\n\n
\n
\n

您必须扩展 base_site.html 模板才能自定义页脚链接、版权文本或添加额外的 JS/CSS 文件。示例文件可在 github 上找到。

\n
\n\n

将自定义的 base_site.html 模板文件复制到您的项目\xe2\x80\x99s main\n application template/admin/ 目录中,并取消注释并编辑\n 您想要扩展的块。

\n
\n\n

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

\n\n
Exception Type: TemplateSyntaxError\n\nException Value:Could not parse the remainder: \'% block footer_links %\' from \'% block footer_links %\'\n
Run Code Online (Sandbox Code Playgroud)\n\n

知道为什么会发生这种情况以及如何解决它吗?

\n\n

基本站点.html:

\n\n
{% extends "admin/base.html" %}\n{% load admin_static %}\n\n{# Additional <head> content here, some extra meta tags or favicon #}\n{#{% block extrahead %}#}\n{#{% endblock %}#}\n\n\n{# Additional CSS includes #}\n{#{% block extrastyle %}#}\n{#  <link rel="stylesheet" type="text/css" href="{% static \'css/my_project.css\' %}" media="all">#}\n{#{% endblock %}#}\n\n\n{# Additional JS files in footer, right before </body> #}\n{#{% block extrajs %}#}\n{#  <script type="text/javascript" src="{% static \'js/my_project.js\' %}"></script>#}\n{#{% endblock %}#}\n\n\n{ Footer links (left side) }\n{{% block footer_links %}}\n{{% endblock %}}\n\n{# Additional header content like notifications or language switcher #}\n{#{% block header_content %}#}\n{#    {{ block.super }}#}\n{#    <div class="header-content">#}\n{#        <!-- First icon column -->#}\n{#        <div class="header-column icon">#}\n{#            <i class="icon-home"></i><br>#}\n{#            <i class="icon-cog"></i>#}\n{#        </div>#}\n{#        <div class="header-column" style="margin-right: 20px">#}\n{#            <a href="/" class="grey">Front-end</a><br>#}\n{#            <a href="" class="grey">One more link</a>#}\n{#        </div>#}\n{#        <!-- Second icon column -->#}\n{#        <div class="header-column icon">#}\n{#            <i class="icon-comment"></i>#}\n{#        </div>#}\n{#        <div class="header-column">#}\n{#            <a href="" class="grey">5 new messages</a>#}\n{#        </div>#}\n{#    </div>#}\n{#{% endblock %}#}\n\n{ Footer branding name (center) }\n{{% block footer_branding %}}\n{{% endblock %}}\n\n\n{ Footer copyright (right side) }\n{{% block copyright %}}\n{  Copyright &copy; 2013 Client<br>Developed by <a href="http://yoursite.com" target="_blank">YourName</a> }\n{{% endblock %}}\n
Run Code Online (Sandbox Code Playgroud)\n

aro*_*cks 2

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

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

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