This error comes when You are trying to get username, passwords from the form. In Login, You are using - > request. POST['username'] which will raise a KeyError exception if 'username' is not in request.