Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 条件语句在Django模板中工作不正常_Python_Html_Django_Django Templates - Fatal编程技术网

Python 条件语句在Django模板中工作不正常

Python 条件语句在Django模板中工作不正常,python,html,django,django-templates,Python,Html,Django,Django Templates,在下面的代码中,educationData是数据库查询结果和范围函数的zip 我在同一个HTML页面中得到了一个完全相似的条件。现在的问题是,每次只有一个有效,也就是说,如果下面的条件有效,那么另一个无效 {% if educationData != 'unavailable' %} {% for edu, counter in educationData %} <div class="row"> <div class="circ"></div>

在下面的代码中,educationData是数据库查询结果和范围函数的zip

我在同一个HTML页面中得到了一个完全相似的条件。现在的问题是,每次只有一个有效,也就是说,如果下面的条件有效,那么另一个无效

{% if educationData != 'unavailable' %}
{% for edu, counter in educationData %}
  <div class="row">
    <div class="circ"></div>
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{counter}}" aria-expanded="false"aria controls="collapse{{counter}}" class="collapsed expand-date">{{edu.year}}</a>
        <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="heading{{counter}}">
            <h4 class="panel-title">
              <span aria-controls="collapse{{counter}}">
                <span class="accordion-heading">{{edu.education_type}}</span>
                </span>

            </h4>
              </div>
                <div id="collapse{{counter}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{counter}}">
                  <div class="panel-body">
                  <h4 class="timeline-title">Started <span><strong>{{edu.education_type}}</strong></span> at <span><strong>{{edu.institution_name}}</strong></span></h4>
                  <div class="timeline-body">
                    <p>{{edu.what_did_you_do_there}}</p>
                  </div>
                </div>
              </div>
            </div>
          </div>
{% endfor %}
{% endif %}
{% if educationData == 'unavailable' %}
  <p>Not Available</p>
{% endif %}
{%if educationData!=“不可用”%}
{对于edu,计数器位于educationData%}
{{教育类型}
开始于{edu.edu.edu.type}
{{edu.你在那里做了什么}

{%endfor%} {%endif%} {%如果educationData==“不可用”%} 不可用

{%endif%}

请帮忙。卡住:(

尝试使用
{%elif%}

{% if educationData != 'unavailable' %}
    <loop here>
{% elif educationData == 'unavailable' %}
    <other html here>
{% endif %}
{%if educationData!=“不可用”%}
{%elif educationData=='不可用'%}
{%endif%}

你的问题令人困惑。什么有效,什么无效?条件是相反的,因此在任何时候,自然只有一个条件是正确的。但是你应该在这里使用
else
而不是单独的
if
。不是这对if。我有另一对if。问题是,如果上面的一对if那么,你是说你的问题在于你没有展示的完全不同的代码位?在这种情况下,你希望我们如何提供帮助?