0

我得到这个异常将试图访问一个图像,我得到了 blog_post_name、blog_post_content,但没有得到图像,看起来像是试图获取它,但它抛出了这个异常:

----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55134)
Traceback (most recent call last):
File "c:\Python27\lib\SocketServer.py", line 593, 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\core\servers\basehttp.py", line 139, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "c:\Python27\lib\SocketServer.py", line 651, in __init__
self.finish()
File "c:\Python27\lib\SocketServer.py", line 710, 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] Se ha anulado una conexi¾n establecida por el software en su    equipo  host
----------------------------------------

模板.html

{% extends "base2.html" %}
{% block content %}
<div class="row">
    <div class="large-6 columns">
        {% if list_all_posts %}
        {% for post in list_all_posts %}
        <ul class="pricing-table">
        <li class="title">{{ post.blog_post_name }}</li>
        <li class="bullet-item">
        <a class="fancybox" href="/media_files/{{ post.blog_post_image}}" title="{{ post.blog_post_content }}" >
            <img src="/media_files/{{ post.blog_post_image}}" alt="" />
        </a>
        </li>
        <li class="description">{{ post.blog_post_content}}</li>
    </ul>
       {% endfor %}
      {% endif %}
      </div>
   </div>
{% endblock %}

视图.py

def blogs(request):
    blog_template = "blog.html"
    list_all_posts = BlogEntry.objects.all()
    print list_all_posts
    return render(request, blog_template, locals())
4

1 回答 1

0

To fix this error, simply increase the request timeout.

In my case I was calling DRF endpoint from NextJs using

api = Axios.create({
    baseURL: C.API_BASE,
    timeout: 1000
})
api.post(....)

My solution in this case is to increase the timeout value

于 2020-11-10T22:05:07.810 回答