目前可以对单个字段,即年份进行模糊查询,请问想要再加入其它字段该怎么做呢,如有帮助必采纳!
def sr2(request):
data_dict = {}
value = request.GET.get('q')
if value:
data_dict = {"year__contains":value}
queryset = models.brown_plant_hopper.objects.filter(**data_dict)
page_object = Pagination(request, queryset)
context = {"queryset": page_object.page_queryset, # 分完页的数据
"page_string": page_object.html(), # 页码
}
return render(request,'sr_list2.html',context)