make searches case insensitive

This commit is contained in:
lauren 2020-12-05 22:14:23 -05:00
parent 4bde0cce90
commit 28dd5563a5

View File

@ -35,10 +35,10 @@ def search_view(request):
if q: if q:
q_list = q.split() q_list = q.split()
context = { context = {
"subject_results": Subject.objects.filter(reduce(operator.or_, (Q(name__contains=x) for x in q_list))), "subject_results": Subject.objects.filter(reduce(operator.or_, (Q(name__icontains=x) for x in q_list))),
"course_results": [[c, c.subject.all()[0]] for c in Course.objects.filter(reduce(operator.or_, (Q(name__contains=x) for x in q_list)))], "course_results": [[c, c.subject.all()[0]] for c in Course.objects.filter(reduce(operator.or_, (Q(name__icontains=x) for x in q_list)))],
"guide_results": Guide.objects.filter(reduce(operator.or_, (Q(name__contains=x) for x in q_list))), "guide_results": Guide.objects.filter(reduce(operator.or_, (Q(name__icontains=x) for x in q_list))),
"tag_results": Tag.objects.filter(reduce(operator.or_, (Q(name__contains=x) for x in q_list))), "tag_results": Tag.objects.filter(reduce(operator.or_, (Q(name__icontains=x) for x in q_list))),
"sq": q "sq": q
} }
return render(request, 'search_results.html', context=context) return render(request, 'search_results.html', context=context)