js:
{{{
$.ajax({
data : {
test:"just test",
},
type : 'post',
url : '/realtime_index',
dataType : 'json',
timeout : 5000,
success : function(result) {
alert(result);
}
});
}}}
view:
{{{
def get_realtime_index(request):
test= request.POST.get('test')
context = {
'test':test + " in view",
}
return HttpResponse(json.dumps(context),
content_type="application/json")
}}}
It works.
But when I changed url like bellow:
url(r'realtime_index$',
login_required(login_url='/auths/login')(views.get_realtime_index),
name='realtime_index'),
when js function called, django throw an exception like this:
{{{
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53555)
Traceback (most recent call last):
File "C:\Python27\lib\SocketServer.py", line 595, in
process_request_thread
self.finish_request(request, client_address)
File "C:\Python27\lib\SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python27\lib\site-
packages\django-1.8.7-py2.7.egg\django\core\servers
\basehttp.py", line 102, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Python27\lib\SocketServer.py", line 653, in __init__
self.finish()
File "C:\Python27\lib\SocketServer.py", line 712, in finish
self.wfile.close()
File "C:\Python27\lib\socket.py", line 279, in close
self.flush()
File "C:\Python27\lib\socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053]
}}}
Can somebody tell me how to fix it?
--
Ticket URL: <https://code.djangoproject.com/ticket/26072>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0
Comment:
I guess this may be [https://bugs.python.org/issue14574 a problem in
Python] instead of an issue with Django. If you can explain why Django is
at fault, feel free to reopen. If you need help debugging, please see
TicketClosingReasons/UseSupportChannels.
--
Ticket URL: <https://code.djangoproject.com/ticket/26072#comment:1>