当我调用 runDelete 时,它会调用run,那么为什么“view没有返回HttpResponse对象”呢?
感谢:)
def run(request, build):
run_list = []
target_dict = {}
target_num = 0
build_id = 0
all_run_list = TestRun.objects.all().order_by('id')
for run in all_run_list:
build_version = run.build.version
build_number = run.build.number
run_build = build_version + '.' + build_number
if (build==run_build):
run_list.append(run)
return render_to_response('run.html', {'run_list': run_list})
def runDelete(request):
run_list = request.POST.getlist('var_delete')
build_id = request.POST.get('build_id')
for run2 in run_list:
run2 = int(run2)
build_id = int(build_id)
build_obj = Build.objects.get(id=build_id)
build_version = build_obj.version
build_number = build_obj.number
build = build_version + '.' + build_number
run(request, build)
答案 0 :(得分:24)
Django视图应返回HttpResponse
个对象。您的视图调用 run
但它不会返回任何内容(请记住,如果没有明确返回其他内容的语句,Python函数会返回None
)。所以改变这一行:
run(request, build)
为:
return run(request, build)
当然,这仅在run
返回HttpResponse
实例时才有效。