Django error. module 'django.http.request' has no attribute 'POST'

Solution 1:

After corrected from requset to request as @gasman pointed. Your views.py for newUser will be

def newUser(request):
    if 'NewUser' in request.POST:
        return render(request,'login/newuser.html')

After this you pointed out that you got

The view login.views.newUser didn't return an HttpResponse object

It is because there is no else part in your code. So if your if condition fails then your view function did not return any response that is why it says didn't return an HttpResponse object. So return HttpResponse if your if condition fails and it will be fine.

def newUser(request):
    if 'NewUser' in request.POST:
        return render(request,'login/newuser.html')
    else:
        return HttpResponse() #<-------- if else condition fails.

In your case why it fail's

Because in your newuser.html your submit button is as follows.

<input type="submit" name="save" value="Save" colspan=2>

And in your views you are comparing the value NewUser with request.POST. So your if condition fails and you are getting this error.

So either change your name as if 'save' in request.POST in your views.py. Or change name="save" with name="NewUser" in your newuser.html your problem will be solved.