1

StreamingHttpResponsedjango框架中使用。响应完成并关闭连接后,我想在数据库中保存一些记录。我应该怎么办?

class foo(View):
    def get(self, request):
        response = StreamingHttpResponse(self._load_stream(request))
        return response

    def _load_stream(self, request):
        yield('<html><body></body></html>')
        time.sleep(5000)
        # close the connection and then save something to database
        
4

0 回答 0