我需要在包含过滤器中执行不区分大小写的搜索,而不是使用完全区分大小写的匹配。
def filter(request, fname, fvalue):
list = HmsPatient.objects.filter(**{fname:fvalue})
c = {'list' : list}
return render_to_response('patient/list.html', c, context_instance=RequestContext(request))
def search(request):
if request.method == 'POST':
fname = request.POST.get('filter_name')
fvalue = request.POST.get('filter_value')
return filter(request, fname, fvalue);
else:
action = HmsPatient().get_search_url()
form = HmsPatientForm()
c = {'form': form, 'action' : action}
c.update(csrf(request))
return render_to_response('search.html', c, context_instance=RequestContext(request))