M
M
maksam072021-11-22 23:29:09
Django
maksam07, 2021-11-22 23:29:09

Django-mptt. How to draw children from a specific element ID?

Good evening. The examples say:
views.py

def show_genres(request):
    return render(request, "genres.html", {'genres': Genre.objects.all()})


genres.html
{% load mptt_tags %}
<ul>
    {% recursetree genres %}
        <li>
            {{ node.name }}
            {% if not node.is_leaf_node %}
                <ul class="children">
                    {{ children }}
                </ul>
            {% endif %}
        </li>
    {% endrecursetree %}
</ul>


But I don’t want to take all the elements of the model, but draw from some ID "a. For example, ID 46 at level 5, under it there are still a lot of children who still have a lot of children. How can I rewrite the code correctly? Sorry, if it’s a banality, but I couldn't find it in the doc.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question