Answer the question
In order to leave comments, you need to log in
How to add a class to the active menu item in django mtpp?
My menu code
<ul class="header_ul navbar-nav mt-2 mt-lg-0 margin-auto">
{% recursetree menu_top %}
<li class="nav-item{% if not node.is_leaf_node %}dropdown{% endif %}">
<a {% if node.slug in request.path %} class="current" {% endif %} {% if not node.is_leaf_node %}class="dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"{% else %} href="/{{node.slug}}"{% endif %}>{% if node.icon %}<i class="fa {{node.icon}}"></i> {% else %}{% endif %}{{node.title}}</a>
{% if not node.is_leaf_node %}
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
{{children}}
</ul>
{% endif %}
</li>
{% endrecursetree %}
</ul>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question