python - 无法解析余数 : '{{' from '{{'

标签 python html django parsing if-statement

我正在尝试创建一个应该显示表格的简单页面。 它假设有几行和几列。但并非每一行都应具有相同数量的列。

这是我的 html 代码,它产生了一个错误:

<html>
  {% for count in machine_count %}
        <tr>
            <td>{{ count }}</td>
            <td>Aufzugmotor</td>

            {% for status in statuses %}
                 {{ status.machine_number}}
                {% if count == {{ status.machine_number }} %}
                    <td class="tableCell">
                        <img class="imageClass" src={{ status.src }}>
                    </td>
                {% endif %}
            {% endfor %}
        </tr>
        {% endfor %}
</html>

statuses 是一个模型,machine_number 是一个字符串元组。

我并没有真正理解我所犯的错误。 是否不能在占位符上使用 if 标签?

最佳答案

{% if count == {{ status.machine_number }} %}

应该是:

{% if count == status.machine_number %}

关于python - 无法解析余数 : '{{' from '{{' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43809791/

相关文章:

python - 使用Nose测试txmongo依赖代码

python - 如何在pygame中停止声音?

python - 传递一个由用户设置的变量作为 os.system() 命令的参数

python - 如何在python中为绘图添加填充?

javascript - 使用 php 中的按钮单击动态向表中添加新行

html - 不显示带有 z-index 的子菜单

javascript - 绝对定位时div消失,父级动态高度

python - 如何在 Django 中处理 PUT 请求? (不在drf中)

python - 按startwith match排序查询结果

python - django - DRF 中的登录 View