python - 将图标添加到 Django 模板表中的特定行

标签 python css django icons

我正在处理 python Django 模板,其中我有一个表,其列为 id、因子 A、因子 B、因子 C。 id、因子 A、因子 B 和因子 C 的值分别为 79、0.56、1.1、1.3。

enter image description here

html模板的代码是这样的:

<table class="table table-bordered">
  <thead>
    <tr>
      <th class="text-center">id</th>
      <th class="text-center">Factor A</th>
      <th class="text-center">Factor B</th>
      <th class="text-center">Factor C</th>
    </tr>
  </thead>
  <tbody >
    <tr ng-class="{'info':aggregateData.Mode, 'closed':!aggregateData.Open}">
      <td class="text-center">{{aggregateData.id}}</td>
      <td class="text-center">{{aggregateData.factor_a}}</td>
      <td class="text-center">{{aggregateData.factor_b}}</td>
      <td class="text-center">{{aggregateData.factor_c}}</td>
    </tr>
  </tbody>
</table

我想为具有 aggregateData.Open true 的行添加一个类似这样的可点击图标。 enter image description here

有人可以建议我如何实现这一点。

最佳答案

试试这个。

<table class="table table-bordered">
  <thead>
    <tr>
      <th class="text-center">id</th>
      <th class="text-center">Factor A</th>
      <th class="text-center">Factor B</th>
      <th class="text-center">Factor C</th>
    </tr>
  </thead>
  <tbody >
    <tr ng-class="{'info':aggregateData.Mode, 'closed':!aggregateData.Open}">
      <td class="text-center">{{aggregateData.id}}</td>
      <td class="text-center">{{aggregateData.factor_a}}</td>
      <td class="text-center">{{aggregateData.factor_b}}</td>
      <td class="text-center">{{aggregateData.factor_c}}</td>
      {% if aggregateData.open == True %}
        <td class="text-center">
          <a href="https://www.google.co.in">
            <img src="/path_toicon.png">    
          </a>
        </td>
      {% endif %}
    </tr>
  </tbody>
</table>

关于python - 将图标添加到 Django 模板表中的特定行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41880629/

相关文章:

python - 加快从 python 中的滚动窗口中查找前 5 个数字的平均值

python - Django Admin 中的反向内联

css - 缩进层次表结构

Python 列表初学者

python - 值错误 : number of input channels does not match corresponding dimension of filter, 512 != 3

python - 在 tox 环境中为 pip install 命令设置 https 代理

html - 图片在网站上不起作用?

javascript - 在一页中加载 100 张图像的最佳方法?

python - 通过代理创建的Django用户无法登录

django - 我接下来的调试步骤是什么? InternalError : current transaction is aborted, 命令被忽略,直到事务 block 结束