Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django html中的段落元素前缀未追加到表中_Python_Html_Django - Fatal编程技术网

Python django html中的段落元素前缀未追加到表中

Python django html中的段落元素前缀未追加到表中,python,html,django,Python,Html,Django,我使用的是Django Web框架,我有一个html表,其中显示了我的一个表中的一些字段。如果没有要显示的字段(查询集中的记录),我将从python传递变量=“0” 在这种情况下,我希望将文本附加到表中,使其显示在我的表下方。但是它出现在我的桌子上方 <div class="1" style="overflow-x:auto;"> <table id="1" class="1"> <tr> <th>H

我使用的是Django Web框架,我有一个html表,其中显示了我的一个表中的一些字段。如果没有要显示的字段(查询集中的记录),我将从python传递变量=“0”

在这种情况下,我希望将文本附加到表中,使其显示在我的表下方。但是它出现在我的桌子上方

<div class="1" style="overflow-x:auto;">
    <table id="1" class="1">
        <tr>
            <th>Heading 1</th>
            <th>Heading 2</th>
        </tr>
        {% ifequal variable "0" %}
            <p>No items to show</p>
        {% else %}
            <--append some fields-->
        {% endifnotequal %}
    </table>
</div>

标题1
标题2
{%ifequal变量“0”%}
没有要显示的项目

{%else%} {%endifnotequal%}
如果我添加字段,这很好,它们会按预期显示,但在另一种情况下,它会在表的前面加上前缀


为什么??救命啊

您不能在
内部使用
,只允许使用

您希望将其更改为:

<div class="1" style="overflow-x:auto;">
    <table id="1" class="1">
        <tr>
            <th>Heading 1</th>
            <th>Heading 2</th>
        </tr>
    {% ifequal variable "0" %}
        </table>
        <p>No items to show</p>
    {% else %}
        <--append some fields-->
    {% endifnotequal %}
</div>

标题1
标题2
{%ifequal变量“0”%}
没有要显示的项目

{%else%} {%endifnotequal%}

可能对你也有帮助

看来你做得不对。我想有一个标签可以把文本放在表格下面,是吗

在末尾使用标记(这是特定于表的标记,如和)

但您需要使用以下CSS:

caption {
    caption-side: bottom;
}
您可以检查此代码笔:


啊,就是这样。因为我可能会附加字段,所以我已将字段移动到标记内部。非常感谢。啊,这是有道理的,我拒绝了你的编辑抱歉之前,我看到这个评论。如果你再次编辑它,我可以批准,我的坏!