加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 为Django admin扩展base_site.html

发布时间:2020-12-20 13:39:45 所属栏目:Python 来源:网络整理
导读:我在我的项目中使用了 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 githu
我在我的项目中使用了 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模板文件复制到项目的主文件中
??应用程序模板/ 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 &copy; 2013 Client<br>Developed by <a href="http://yoursite.com" target="_blank">YourName</a> }
{{% endblock %}}

解决方法

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

{# 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的新副本

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读