I am using django-mptt
library for the category. I could show the list of categories in template but I wanted to indent it properly so user can know which is a main category and which one is sub-category and etc. The way i tried to structure is
{% recursetree nodes %}
<li class="node">
<a href="/category/{{ node.get_absolute_url }}"
class="{% if not node.is_leaf_node and not node.is_root_node and node.is_child_node %} child_parent {% elif node.is_leaf_node and not node.is_root_node %}leaf_node{% endif %}">
{{ node.name }}
{% if node.is_root_node %}
<span class="badge">{{ node.get_count_children }}</span>
{% endif %}
</a>
{% if not node.is_leaf_node %}
<ul class="children">
<li>{{ children }}</li>
</ul>
{% endif %}
</li>
{% endrecursetree %}
This yields the following design of category
Here Dressing Table is a child of Bedroom Items like Bed and Almirah not a child of Bed. How could i fix this? I know the problem is here
<a href="/category/{{ node.get_absolute_url }}"
class="{% if not node.is_leaf_node and not node.is_root_node and node.is_child_node %} child_parent {% elif node.is_leaf_node and not node.is_root_node %}leaf_node{% endif %}">
but could not fix this issue
Not the dressing table in the screenshot