Skip to content

Unable to "stream" the response #14

@arashyousefi

Description

@arashyousefi

Hi

I'm having trouble using this library to actually stream the response. When exporting, only a small chunk of data will be sent at first and then the rest of data is sent at the same time that all serialization is done.

here is the code I'm using (inside a View) which is the same as the example in the docs:

def serializer(x):
    time.sleep(1)
    return [d.values() for d in ReportSerializer(x, many=True).data]

stream = xlsx_streaming.stream_queryset_as_xlsx(qs, template, serializer=serializer, batch_size=10)
response = StreamingHttpResponse(stream, content_type='application/vnd.xlsxformats-officedocument.spreadsheetml.sheet')
response["Content-Disposition"] = 'attachment; filename="report.xlsx"'
return response

When I use a cURL request to the view, I get a chunk of data very fast, but the rest of data arrives at the same time when the queryset is exhausted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions