Exception happened during processing of request from 에러 해결하기
Exception happened during processing of request from ('127.0.0.1', 49657)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in __init__
self.handle()
File "/Users/woojongseon/Python-project/bookmark/venv/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/woojongseon/Python-project/bookmark/venv/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
이 에러는 장고에서 ajax 를 쓸때 겪을 수 있다.
ajax 를 form 안에서 사용하면 form 의 submit 이 ajax 응답을 방해해서 생기는 에러이다.
$("#addUser").click(() => {
let email = $("#user_email").val();
let folder_no = $("#folder_no").val();
$.ajax({
url: '/add/user',
type: 'POST',
dataType: "json",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
email: email,
folder_no: folder_no,
},
success: (data) => {
alert(data['message']);
return;
},
error: () => {
alert("error");
return;
}
})
});
ajax 코드를 실행시키는 <button> </button> 태그를 form 에 담지 않으면 해결된다.
<div class="modal-footer">
<div class="form-group">
<button id="addUser" class="btn btn-primary">추가하기</button>
<input type="hidden" name="csrfmiddlewaretoken" id="csrftoken"
value="{{ csrf_token }}">
</div>
<div class="form-group">
<button type="button" class="btn btn-secondary" data-dismiss="modal">닫기
</button>
</div>
</div>
'Python > 장고 Django' 카테고리의 다른 글
django mysqlclient 설치 에러 (0) | 2020.03.27 |
---|---|
visual studio code 에서 django 자동완성이 안 될때 해결 (9) | 2019.12.07 |
장고 프로젝트 시작 명령어 정리 (0) | 2019.06.18 |
댓글