ascending=True not working in django-mptt

132 views Asked by At

Hi good day I'm currently following Django-MPTT documentation and I have a problem using ascending=True. Here's my code:

views.py

def show_genres(request):
    Try01 = Genre.objects.filter(name="Rock")

    context = {'genres': Genre.objects.all(), 
                'sample_ancestor': Try01.get_ancestors(ascending=True, include_self=True)}
    return render(request, "sampletemp/startup.html", context)

when I'm using ascending=True an error occurs saying:

Exception Value: get_queryset_ancestors() got an unexpected keyword argument 'ascending'

How can I fix it. Thank you in advance!

1

There are 1 answers

0
2293980990 On

You are using the wrong method

models.get_ancestors has an ascending field see here

managers.TreeManager.get_queryset_ancestors howerver has not, as shown here