Opened 9 years ago
Closed 9 years ago
#26072 closed Uncategorized (invalid)
Errno 10053 occured when use login_required view with ajax
Reported by: | JunLuo | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
url.py:
url(r'realtime_index$',views.get_realtime_index, name='realtime_index'),
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?
Note:
See TracTickets
for help on using tickets.
I guess this may be 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.