django的filter过滤集合的功能有contains和icontains字段
contains是精确查询,icontains是忽略大小写的模糊查询
params = json.loads(request.body) # dict类型 name = params.get("name", "") if name: filter_dict["name__contains"] = name res_obj = 模型类名.objects.filter(**filter_dict).order_by("-create_time")