社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Django

Django HTML模板表呈现

Jason Liu • 5 年前 • 1825 次点击  

我想把一张桌子渲染成这样:

<table>
  <tr>
    <td>some data</td>
    <th>special one</th>
    <td>some data</td>
      ...
    <td>some data</td>
  </tr>
  ...
</table>

有一个 solution

<table>
  {% for rowval in results %}    
     <tr>
     {% for val in rowval %}
      <td>{{val}}</td>
     {% endfor %}
    </tr>
  {% endfor %}
</table> 

但在我看来 th 如果有记录,则排在第二位。

还有一个 solution 不如下面的答案保留部分表, td tr 在视野中。

有办法实现这个功能吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56752
 
1825 次点击  
文章 [ 1 ]  |  最新文章 5 年前