Extending base_site.html for Django admin

7.4k views Asked by At

I am using a Django Suit in my project. Django suit comes with a default footer which I would like to change or get rid of. According to the instructions on the docs:

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.

Copy customized base_site.html template file to your project’s main application template/admin/ directory and un-comment and edit the blocks you would like to extend.

But when I do that, whenever i uncomment one of their blocks I end up with the following error:

Exception Type: TemplateSyntaxError

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

Any idea why is this happening and how can I solve it?

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 %}}
1

There are 1 answers

2
arocks On BEST ANSWER

You have got the syntax of Django templates wrong. Here is the correct way to uncomment the footer part of the file:

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

Since these mistake are there throughout the file, please work with a fresh copy of base_site.html