[英]Recursive comment system in django
我的網站有一個評論系統,我將所有評論與相關帖子一起傳遞,但是當我循環瀏覽評論並顯示每條評論是子評論時,它會將其后的孩子顯示為獨立評論。
{% load custom_tags %}
{% for comment in page_obj %}
<div class="comments">
<h6>
<a href="{% url 'main:creator' comment.publisher.id %}">
{{comment.publisher.name}}
</a>
</h6>
<span>{{ comment.created_on}}</span>
<div>
{{comment.text}}
<br>
</div>
{% if comment.children %}
<ul style="margin-right: 5%;">
{% include "post/comment.html" with page_obj=comment.children %}
</ul>
{% endif %}
</div>
{% endfor %}
您混淆margin-right
和margin-left
。 設置margin-right: 5%;
不會添加不會移動子評論的右邊距。 你需要替換margin-right: 5%;
margin-left: 5%;
.
另一種可能性與父div
的特性有關。 5%
在某些情況下可能不起作用。 您可以嘗試用50px
之類的東西替換它,以防之前的選項不起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.