[Answered ]-Python return function error


By reading the code and the error, I assume that validate is a view. A view must always return a HttpResponse. So if you want to return a response indicating a boolean value, indicating if captchavalue == key, do:

from django.http import HttpResponse

def validate(request):
 captchavalue = mc.get(str(id))

 return HttpResponse(captchavalue == key)

I’m not 100% sure about the import line, but it’s something very similar.



I don’t know much Django, but it seems it expects you to return a response object instead of a bool value (True / False).

Maybe your code should like more like this:

if captchvalue == key:
    return HttpResponse('HTML Page saying OK')
    return HttpResponse('HTML Page saying Error')

Leave a comment