Django MPTT how to remove indentation from html template

I am using django MPTT model in my template and just want to remove indentation. Now it’s look like this:

enter image description here

how to remove indentation from html template?

here is my html:

 {% load mptt_tags %}
 {%  recursetree contact %}


      {% if not node.is_leaf_node %}
      <div class="children pl-2 pl-md-5">
      {{ children }}

{% endif %}
{% endrecursetree %}

I am not familiar with the django-mptt library, so I can’t specifically address your question. However, in general, you can always override a library’s template with your own. With your own template, you can make the tree appear however you like. (Or, in this case, replacing their templatetag with your own.)

One thing I just noticed is that you’ve got a lot of “hanging div” tags. You’ve got a <div ...> before {{ children }} but no </div> after. My first shot would be to remove that div tag to see what happens.

1 Like