2016-05-11 24 views
0

在Django教程中,我遇到了index.html文件的一個問題。 我無法處理此異常:Django:第14行的塊標記無效:'else'。你忘了註冊或加載這個標籤嗎?

第14行上的塊標記無效:'else'。你忘了註冊或加載這個標籤嗎?

我的index.html是這樣的:

{% if latest_questions %) 
    <ul> 
     {% for question in latest_questions %} 
      <li> <a href="/polls/{{question.id}}"><b>{{question.question_text}}</b></a></li> 
     {% endfor %} 
    </ul> 
{% else %} 
    Something else. 
{% endif %} 

我真的不明白爲什麼它不承認 「其他」。

+0

'%如果latest_questions%)'這是在問題或代碼一個錯字?它應該是'{%if latest_questions%}'。 – AKS

+0

對不起,我沒有這個複製。它在{%開頭。 – Ula

+0

但不是最後?最後oyu有'%}'應該是'%}',對吧? – AKS

回答

1

問題出在您的if標籤上。

替換:

% if latest_questions %) 

有:

{% if latest_questions %} 
+0

謝謝!我沒有看到這一點,我專注於「其他」 – Ula

+0

@Ula yep,其實只是錯誤提到了'else'標籤,因此可能會引起混淆 –

相關問題