Answer the question
In order to leave comments, you need to log in
How to display only the first two children in django-mptt?
There is this pattern:
{% recursetree product.comments.all %}
{% with comment=node %}
<div class="comment-item_lvl-{{ comment.level|add:'1' }}">
{% include 'product/comment.html' %}
</div>
{% endwith %}
{% if not node.is_leaf_node %}
{{ children }}
{% endif %}
{% endrecursetree %}
Answer the question
In order to leave comments, you need to log in
Level empirically determine yourself
{% recursetree product.comments.all %}
{% with comment=node %}
<div class="comment-item_lvl-{{ comment.level|add:'1' }}">
{% include 'product/comment.html' %}
</div>
{% endwith %}
{% if not node.is_leaf_node and node.level <= 2 %}
{{ children }}
{% endif %}
{% endrecursetree %}
{% recursetree product.comments.all %}
<div class="comment-item_lvl-{{ node.level|add:'1' }}">
{% include 'product/comment.html' with comment=node %}
</div>
{% if not node.is_leaf_node and node.level <= 2 %}
{{ children }}
{% endif %}
{% endrecursetree %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question