Django : An established connection was aborted by the software in your host machine

风格不统一 提交于 2021-02-04 21:10:31

问题


I am getting this error when i add a specific line in the post request.

views.py

class LoginVerify(View):
    print('login')
    email =""
    pswd = ""
    username =""

    def post(self,request,*args,**kwargs):
        print("post called")
        self.email = request.POST['email']
        self.pswd = request.POST['pswd']
        self.username = User.objects.get(email=self.email).username
        return HttpResponse("Invalid user")

If I add self.username = User.objects.get(email=self.email).username then it is showing the error, otherwise it is working fine.

Why it is happening, how can I solve this?


回答1:


I usually get this when running on my local machine in debug mode usually happens if the server responds to a request and the client has already closed the connection. You may ignore the error or use a different production server such as gunicorn which has better server socket handling. FYI i see this error on python 2.7



来源:https://stackoverflow.com/questions/29619278/django-an-established-connection-was-aborted-by-the-software-in-your-host-mach

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!