段落元素前缀不附加到django html中的表格(Paragraph element prepending not appending to table in django html)

编程入门 行业动态 更新时间:2024-10-21 09:22:31
段落元素前缀不附加到django html中的表格(Paragraph element prepending not appending to table in django html)

我正在使用Django Web Framework,我有一个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>

如果我附加字段这可以正常工作,它们会按预期显示,但在另一种情况下,它会优先于表格而不是......

为什么? 帮帮我!

I'm using the Django Web Framework and I have a html table displaying some fields from one of my tables. If there are no fields to display (records in a queryset), I pass variable = "0" from python.

I want to append text to the table in this case so it appears underneath my table. But it's appearing above my table....

<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>

If I'm appending the fields this works fine they appear as expected, but in the other case it prepends above the table instead...

Why? Help!

最满意答案

您不能在<tr>仅使用<p> <td>并允许<th> 。

你想把它改成:

<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>

这个问题也可能对你有所帮助

You can't use <p> inside a <tr> only <td> and <th> are allowed.

You'd want to change it to:

<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>

This question might be helpful for you too

更多推荐

本文发布于:2023-04-28 01:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1330297.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:前缀   段落   表格   元素   django

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!