html - 模型中的引导表
问题描述
我有一个表,我正试图将静态模拟数据转换为真实的实时 SQLite3 数据。我希望在我的 HTML 代码中显示我的 SQLite3 表,包括我的所有三列(问题 | 答案 | Pub_Date),然后在表中显示值。
我当前的代码(如下)添加了问题列表,但它是将它们作为值从左到右而不是上下添加(下面的屏幕截图)。我需要调整什么来显示我的简单表格而不是假数据?
<table class="table table-hover">
<thead>
<tr style="font-family: Graphik Black; font-size: 14px">
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
</tr>
</thead>
<tbody>
<tr style="font-family: Graphik; font-size: 12px">
<th scope="row" class="container">1</th>
{% for question in latest_question_list %}
<td><li style="font-weight: 500;"><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li></td>
{% endfor %}
<td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px" data-toggle="modal" data-target="#new">Edit</button></td>
</tr>
<tr style="font-family: Graphik; font-size: 12px">
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px" data-toggle="modal" data-target="#new">Edit</button></td>
</tr>
<tr style="font-family: Graphik; font-size: 12px">
<th scope="row">3</th>
<td colspan="2">Larry the Bird</td>
<td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px"data-toggle="modal" data-target="#new">Edit</button></td>
</tr>
</tbody>
</table>
解决方案
试试这个:
<table class="table table-hover">
<thead>
<tr style="font-family: Graphik Black; font-size: 14px">
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
{% for question in latest_question_list %}
<tr style="font-family: Graphik; font-size: 12px">
<td><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li></td>
<td>{{ question.answer }}</td>
<td>{{ question.pub_date }}</td>
<td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px" data-toggle="modal" data-target="#new">Edit</button></td>
</tr>
{% endfor %}
</tbody>
</table>
推荐阅读
- php - 如何在容器外访问 logo.svg
- amazon-web-services - 如何通过云形成更新使用云形成创建的 s3 存储桶
- django - 如何使用 Django html 模板中的最后一个过滤器获取 JSON 数据?
- angular - 如何键入扩展抽象泛型类的子类的方法
- android - 当我尝试将一些包添加到我的 MainAplication.java 时,在 React Native App 中构建失败
- node.js - 【M1芯片Mac】Nuxt构建太慢
- sql-server - 将 SQL Server 数据库还原到 rds 失败
- reactjs - 如何在 props 中传递 CSS 模块?
- java - C-style arrays do not work with records anymore
- python - 显示评论比帖子点赞数多的帖子