标签: streaminghttpresponse

是否可以使用 StreamingHttpResponse 生成 PDF,因为可以使用 CSV 生成大型数据集?

我有一个大型数据集,我必须为其生成 CSV 和 PDF。对于 CSV,我使用本指南:https : //docs.djangoproject.com/en/3.1/howto/outputting-csv/

import csv

from django.http import StreamingHttpResponse

class Echo:
    """An object that implements just the write method of the file-like
    interface.
    """
    def write(self, value):
        """Write the value by returning it, instead of storing in a buffer."""
        return value

def some_streaming_csv_view(request):
    """A view that streams a large CSV file."""
    # Generate a sequence of rows. The range is based on the maximum number of
    # rows that can be handled by a single …
Run Code Online (Sandbox Code Playgroud)

python django large-data streaminghttpresponse

13
推荐指数
1
解决办法
476
查看次数