html - 在引导表中为空行添加消息
问题描述
我正在开发一个 Django 项目,但对 bootstrap 和 css 来说相对较新。我有一张带有书籍库存的桌子,它看起来很好,直到里面有记录。但是当没有记录时,我想显示一个占位符“还没有添加书籍”。我尝试了多种方法,但我无法这样做。这是我的 html 文件:
<table class="table table-hover table-bordered">
<thead class="thead-light">
<tr>
<th scope="col">Title</th>
<th scope="col">Author</th>
<th scope="col">Genre</th>
<th scope="col">Available</th>
<th scope="col">Add Date</th>
</tr>
</thead>
<tbody>
{% if books.count > 0 %}
{% for row in books %}
<tr>
<td>{{row.title}}</td>
<td>{{row.author}}</td>
<td>{{row.genre}}</td>
<td>{% if row.available %}Yes{% else %}No{% endif %}</td>
<td>{{row.date}}</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td>No Books added yet !</td>
</tr>
{% endif %}
</tbody>
</table>
这样做,占位符只是在第一个单元格上进行:
如何编辑此单元格以使该单元格显示为完整的行?
解决方案
推荐阅读
- flutter - 创建新的颤振项目时出现此错误错误:无法解析 URL“https://pub.dartlang.org”
- python - 如何使用for循环删除数据框中的行
- python - 如何在驱动程序 selenium python 中设置引用者?
- python - 如何删除第一行号列熊猫?
- arrays - 评估COM接口返回的非变量数组导致的VBScript类型不匹配错误可以通过更改语言来解决吗?
- git - Git:撤消所有直到分支开始
- unity3d - 如何在场景中的另一个位置复制实时 3D 对象?
- sql - 计算重复状态的迭代次数
- python-3.x - 如何将此脚本放入函数中?
- google-bigquery - 为什么我的 Stackdriver 导出接收器仅将最新的审核日志加载到 BigQuery 中而没有历史记录?