From 28dd5563a5f630bac0c74d1d389e7d9246e6833d Mon Sep 17 00:00:00 2001 From: lauren Date: Sat, 5 Dec 2020 22:14:23 -0500 Subject: [PATCH] make searches case insensitive --- studyguides/apps/courses/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/studyguides/apps/courses/views.py b/studyguides/apps/courses/views.py index adc4919..84cf442 100644 --- a/studyguides/apps/courses/views.py +++ b/studyguides/apps/courses/views.py @@ -35,10 +35,10 @@ def search_view(request): if q: q_list = q.split() context = { - "subject_results": Subject.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__contains=x) for x in q_list)))], - "guide_results": Guide.objects.filter(reduce(operator.or_, (Q(name__contains=x) for x in q_list))), - "tag_results": Tag.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__icontains=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__icontains=x) for x in q_list))), "sq": q } return render(request, 'search_results.html', context=context)