我正在使用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
更多推荐
发布评论