AJAX로 장고 백엔드에 요청하려고합니다. AJAX가 작동하는 부분을 얻었으나 이제 mpld3 그림을 페이지에 표시하려고합니다. 여기Django보기의 Mpld3 - "NoneType"개체에 "split"속성이 없습니다.
<form id="pointform" method="POST">
{% csrf_token %}
<div class="row">
<div class="col-lg-6 col-md-6">
<input name="x_coord" type="text" accept=""id="x_coordinate" class="form-control form-control-md" type="text" placeholder="X-Coordinate">
</div>
<div class="col-lg-6 col-md-6">
<input name="y_coord" type="text" id="y_coordinate" class="form-control form-control-md" type="text" placeholder="Y-Coordinate">
</div>
</div>
<button style="width: 100%" type="submit" class="btn btn-danger">Add Point</button>
</form>
내 AJAX 요청한다 : 이것은 내보기입니다
$.ajax({
type: "POST",
url: url,
data: data,
dataType: "json",
success: function(json){
},
});
: 여기
import mpld3
import matplotlib.pyplot as plt
X = []
y = []
def get_figure(request):
x_coord = request.POST['X']
y_coord = request.POST['Y']
X.append(x_coord)
y.append(y_coord)
fig = plt.figure()
plt.scatter(X, y)
model = mpld3.fig_to_html(fig)
data = {'Model': model}
return JsonResponse(data)
전체 역 추적이에서 오는
이
는 HTML 양식입니다 명령 줄 :File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\exception.py", line 39, in inner
response = get_response(request)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\User\Desktop\mlapp06\regression\views.py", line 24, in get_regression_graph
fig = plt.figure()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\pyplot.py", line 535, in figure
**kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 81, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 98, in new_figure_manager_given_figure
icon_img = Tk.PhotoImage(file=icon_fname)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 3394, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 3350, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
RuntimeError: main thread is not in main loop
[05/Oct/2017 15:54:51] "POST /ajax/get_regression_graph/ HTTP/1.1" 500 18714
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\socket.py", line 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] Eine bestehende Verbindung wurde softwaregesteuert
durch den Hostcomputer abgebrochen
[05/Oct/2017 15:54:51] "POST /ajax/get_regression_graph/ HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53724)
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\socket.py", line 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] Eine bestehende Verbindung wurde softwaregesteuert
durch den Hostcomputer abgebrochen
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\servers\basehttp.py", line 95, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\socketserver.py", line 625, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\socketserver.py", line 681, in __init__
self.handle()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\servers\basehttp.py", line 174, in handle
handler.run(self.server.get_app())
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\wsgiref\simple_server.py", line 36, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
왜 그런 일이 발생했는지에 대한 제안이 있으십니까?
미리 감사드립니다.
는 전체 스택 추적을 게시 할 수 있습니다 :이 비슷한 질문이 문제를 해결하는 데 도움 여부
는확인하시기 바랍니다? – pazitos10
좋아요, done ----- – OhMad
'self.status'가'None' 이외의 것으로 설정되어 있다고 가정하기 때문에 발생하지만'None'입니다. –