Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to "stream" the response #14

Open
arashyousefi opened this issue Aug 21, 2021 · 0 comments
Open

Unable to "stream" the response #14

arashyousefi opened this issue Aug 21, 2021 · 0 comments

Comments

@arashyousefi
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant