<div class="page-header">
{% if user.is_authenticated %}
<a href="{% url 'post_new' %}" class="top-menu"><span class="glyphicon glyphicon-plus"></span></a>
{% endif %}
<h1><a href="/">Django Girls Blog</a></h1>
{% if user.is_anonymous %}
<h4><a href="/login">LogIn</a></h4>
{% endif %}
{% if user.is_authenticated %}
<a href="{% url 'post_draft_list' %}" class="top-menu"><span class="glyphicon glyphicon-edit"></span></a>
{% endif %}
{% if user.is_authenticated %}
<h3><a href="/user">{{ user }}</a></h3>
<h4><a href="/logout">LogOut></a></h4>
{% endif %}
答案 0 :(得分:0)
绝对。检查当前页面是否为主页,如果不是,则使用css隐藏该按钮。像这样:
<button {% if request.path != '/' %} style="display: none;" {% endif %}>My Button</button>