[Answer]-How to display the active status element alone in template

1👍

You’re trying to use a QuerySet as an object, which is faulty.

What you wanted to do in the first place is to accept one more parameter to your QuerySet.
So you could filter on what came from your request.POST

Types.objects.filter(..., is_active=True)

Views.py

def what(request):
    report = Report.objects.get(user=request.user.id)
    if 'is_active' in request.POST:
        types = Types.objects.filter(user=user.id, parent_type_id=None, is_active=True).order_by('title')
    else:
        types = Types.objects.filter(user=user.id, parent_type_id=None, is_active=False).order_by('title')
        typelist = Types.objects.filter(user=user.id,parent_type_id__isnull=False).order_by('title')
    return render(request, 'incident/what.html',
        {
            'newreport_menu': True,
            'types':types,
            'checked_ones':checked_ones,
            'typelist': typelist,
     })  

I simplified your code some.

Leave a comment