0
所以在我的主頁中我根據用戶是否登錄而擴展了2個東西。然後,如果他們試圖登錄,並且失敗了,我想投入到紅:那麼奇怪的程序塊/擴展Django中的交互
{% extends extendVar %} #in this case, extendvar=notLoggedIn.html
{% block signIn %}
{% if failure %}
<div class="form-group has-error">
<input type="email" id="email" name="email" placeholder="Email" class="form-control">
</div>
<div class="form-group has-error">
<input type="password" name="password" placeholder="Password" class="form-control">
</div>
{% endif %}
{% endblock %}
notLoggedIn.html從標題頁包括:
<div class="container" style="">
{% include 'header.html' %}
</div>
這有一個塊標籤:
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-left">
<a class="" href="#">
<img alt="Brand" src="{% static 'images/Logo.png' %}" style="height:auto; max-width:470px; margin-top:-22px; margin-bottom:-30px; padding-right:10px;">
</a>
</ul>
<ul class="nav nav-pills pull-right">
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-right" action="{% url 'signIn' %}" method="POST">
{% csrf_token %}
{% block signIn %}
<div class="form-group">
<input type="email" id="email" name="email" placeholder="Email" class="form-control">
</div>
<div class="form-group">
<input type="password" name="password" placeholder="Password" class="form-control">
</div>
<button class="btn btn-primary btn" href="" role="button" style="">Sign in </button>
{% endblock %}
</form>
</div>
</ul>
</nav>
項目名稱</H3> - >
我唯一的問題是,因爲我在NotLoggedIn中包含標題,然後擴展它,它不保留塊標記,因此signIn塊不起作用。如果不是做包含頭文件,我只是硬編碼,塊完美地工作。有任何想法嗎?