Python 大佬帮忙看一下,django 查询结果为 None 时,报错的问题

睡梦罗汉虎 · 2022年09月16日 · 1989 次阅读

data_before = TpBaseStatistics.objects.filter(create_time__range=[startDateBefore, endDateBefore]).aggregate(run_tc_num_before=Coalesce(Sum('run_tc_num', 0)), testcase_num_before=Coalesce(Sum('testcase_num'),0))

如果 run_tc_num 或者 testcase_num 为 None 时,django 高版本会报错,请问还有其他查询方法,如果查询结果为 None 时,默认为 0 吗?

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册