Salim
Salim

Reputation: 1

ValueError at /

The view demo.views.index didn't return an HttpResponse object. It returned None instead.

@csrf_exempt
def index(request):
    if request.method == 'POST':
        session_id = request.POST.get('sessionId')
        service_code = request.POST.get('serviceCode')
        phone_number = request.POST.get('phoneNumber')
        text = request.POST.get('text')

        response = ""


 if text == "":
            response = "CON What would you want to check \n"
            # response .= "1. My Account \n"
            response += "1. My Phone Number"


        elif text == "1":
            response = "END My Phone number is {0}".format(phone_number)

        return HttpResponse(response)

Upvotes: 0

Views: 298

Answers (1)

Alienware
Alienware

Reputation: 47

I guessed your code is not properly indented.

Your Httpresponse is breaking out of elif condition, I assume this is why you are having this error. make sure to always follow convention and adopt best practices.

Upvotes: 1

Related Questions