我在我的项目中使用Django Suit。 Django套装带有默认页脚,我想改变或摆脱它。 根据文档上的说明:
您必须扩展base_site.html模板以自定义页脚链接,版权文本或添加额外的JS / CSS文件。示例文件可用 在github上。
将自定义的base_site.html模板文件复制到项目的主文件中 应用程序模板/ admin /目录并取消注释和编辑 你想扩展的块。
但是当我这样做时,每当我取消注释其中一个块时,我最终会出现以下错误:
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 © 2013 Client<br>Developed by <a href="http://yoursite.com" target="_blank">YourName</a> }
{{% endblock %}}
答案 0 :(得分:1)
你有Django模板的语法错误。以下是取消注释文件页脚部分的正确方法:
{# Footer copyright (right side) #}
{% block copyright %}
Copyright © 2013 Client<br>Developed by <a href="http://yoursite.com" target="_blank">YourName</a>
{% endblock %}
由于整个文件都存在这些错误,请使用base_site.html
的新副本