[Answer]-The views didn't return an HttpResponse object

-1πŸ‘

βœ…

def register(req): 
        if req.method == "POST":
                uf = UserForm(req.POST)
                if uf.is_valid():
                        ....
                        return HttpResponse('ok') 
                # If control flow is reach here, nothing is returned.
        else:
                uf = UserForm()
                return render_to_response('register.html',{'uf':uf})

If an invalid POST request is come, the view will return nothing. (implicitly None)

Try following:

def register(req): 
    if req.method == "POST":
        uf = UserForm(req.POST)
        if uf.is_valid():
            ....
            return HttpResponse('ok') 
    uf = UserForm()
    return render_to_response('register.html',{'uf':uf})
πŸ‘€falsetru

2πŸ‘

You need to decrease the indent of the last line. That should be caught both by the case where it is not a POST, and when it is a POST but the form is invalid.

Leave a comment