Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django "view didn't return an HttpResponse object."

Tags:

django

when i call runDelete, then it will call run, so why "view didn't return an HttpResponse object" happen?

thanks:)

views.py

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)
like image 1000
LoveTW Avatar asked Aug 20 '10 09:08

LoveTW


1 Answers

Django views are expected to return HttpResponse objects. Your view does call run but it does not return anything (remember that Python functions return None in the absence of a statement explicitly returning something else). So change this line from:

run(request, build)

to:

return run(request, build)

Of course this will only work if run returns an HttpResponse instance.

like image 191
Manoj Govindan Avatar answered Oct 15 '22 19:10

Manoj Govindan