如何在jinja中迭代多个html段落



我想遍历包含的数据库

  1. 标题
  2. 段落

如何将内容拆分为两列?

希望制作此代码:

{% for stor in story %}
<h1>{{stor.title}}</h1>
<p class = "story">{{stor.body}}</p> 
{% endfor %}

看起来像这样:

<div class="container">
<div class="row">
<div class="col-md">
<h1>header text</h1>
<p>paragraph text</p>
</div>
<div class="col-md">
<h1>header text</h1>
<p>paragraph text</p>
</div>
</div>
</div>

同时显示来自数据库的文本

使用HTML Tables在列中显示数据。你可以这样做:

<table>
<tr>
<th>Title</th>
<th>Story</th>
</tr>
{% for stor in story %}
<tr>
<td>{{stor.title}}</td>
<td>{{stor.body}}</td>
</tr>
{% endfor %}
</table> 

有关HTML Tables的更多详细信息:https://www.w3schools.com/html/html_tables.asp

最新更新