使用for循环在Django temp中显示值

2024-06-16 08:45:28 发布

您现在位置:Python中文网/ 问答频道 /正文

如果我使用“for loop”,所有来自Db的数据都是垂直显示的。为了透明起见,我写了一个没有HTML的例子。第二个密码“我的.html“是HTML代码。我想被水平显示的分区(或表)。如果我跑了我的.html我有两个垂直显示的分区,如何水平放置它们?我想水平地显示两个分区(或表)并将其值支柱1必须在分区或表格中垂直显示。在

{% for post in posts %}
    {{post.option_one}}
    {{post.option_two}}
{% endfor %}

在我的.html在

^{pr2}$

Tags: 数据代码loop密码fordbhtml水平
1条回答
网友
1楼 · 发布于 2024-06-16 08:45:28

循环整个内容..只需循环col-sm-4 col-xs-12。 你的“for loop”和endingtag在html中的位置不正确。 这里有一个例子

       <!  Container (Pricing Section)  >
<div id="pricing" class="container-fluid">
  <div class="text-center">
    <h2>Pricing</h2>
      <h4>blabla</h4>
  </div>

    <div class="row slideanim-'inline'">
        {% for post in posts %}
    <div class="col-sm-4 col-xs-12">


      <div class="panel panel-default text-center">
        <div class="panel-heading">

      <h1><a href="">{{ post.offer_option}}</a></h1>
        </div>
          <div class="panel-body">
              <p><strong>20</strong> {{post.prop_one}}</p>
              <p><strong>20</strong>{{post.prop_two}} </p>
              <p><strong>20</strong>{{post.prop_three}}</p>
          </div>
           <div class="panel-footer">
            <h3>{{ post.price}}</h3>
            <h4>{{ post.period}}</h4>
           </div>
          <button class="btn btn-lg">Sign Up</button>
        </div>

      </div>{% endfor %}
    </div>

相关问题 更多 >