我在搜索字段中有六个文本框,用户可以输入任何一个值。我通过以下方式捕捉这些价值观:
if request.GET:
result_list = []
client_build = request.GET.get('client_build','')
app_build = request.GET.get('app_build','')
ws_build = request.GET.get('ws_build','')
asset = request.GET.get('asset','')
feature = request.GET.get('feature','')
test_type = request.GET.get('test_type','')
result_lists = result.objects.filter(asset=asset,feature=feature, test_type=test_type)
job_list = job.objects.filter(client_build=client_build ,app_build = app_build,ws_build = ws_build)
当我尝试过滤它们时,它给出“invalid literal for int() with base 10: ''”错误!如何仅获取用户输入的值并相应地在过滤器中查询。
我提到了这篇文章Django - 多个字段搜索问题,但我有六个文本框做多个 if 和 else 不是我想要的。