[Answered ]-Django Exclude Model Objects from query using a list

1👍

The answer is simple, I was not comparing objects correctly in the filters, so
the correct statement would be:

program_results =  (Program.objects.filter(
        Q(title__icontains=query) |
        Q(library__icontains=query) |
        Q(mc__icontains=query) |
        Q(producer__icontains=query) |
        Q(editor__icontains=query) |
        Q(remarks__icontains=query) )&
        (Program.objects.exclude(id__in=Program.objects.filter(id__in=unique_programs))))

👤Todd B

Leave a comment