2014-07-07 46 views
0

我知道這個問題遍佈整個stackoverflow,但它的這個特定實例已經丟失了。原因是,我週期性地收到了這個錯誤 - 根本沒有改變HTML文件。無效的塊標記,預期'endblock'

這個問題似乎是在這裏:

{% extends "base.html" %} 
{% load static %} 
{% load support_tags %} 

{% block content_header %} 
<h1>Header</h1> 
{% endblock content_header %} 

{% block new-main-area %} 
     {% ticket_categories as categories %} {# Problem is here #} 
      <option value="None">Select a Category</option> 
     {% for cat in categories %} 
      <option value="{{cat.slug}}">{{cat}}</option> 
     {% endfor %} 
{% endblock new-main-area %} 

{% block extrascripts_bottom %} 
{% endblock extrascripts_bottom %} 

謝謝!

回答

3

恕我直言,代碼被濫用with標籤:

替換以下行:

{% ticket_categories as categories %} <!-- Problem is here --> 
    <option value="None">Select a Category</option> 
{% for cat in categories %} 
    <option value="{{cat.slug}}">{{cat}}</option> 
{% endfor %} 

有:

{% with ticket_categories as categories %} <!-- Problem is here --> 
    <option value="None">Select a Category</option> 
{% for cat in categories %} 
    <option value="{{cat.slug}}">{{cat}}</option> 
{% endfor %} 
{% endwith %} 

或(with是沒有必要的):

<option value="None">Select a Category</option> 
{% for cat in ticket_categories %} 
    <option value="{{cat.slug}}">{{cat}}</option> 
{% endfor %} 
+0

完全工作(他們兩人)。非常感謝你!我一定錯過了'與'部分的語法。 – Kris

相關問題