Django的視圖中的多個PDF當用戶點擊下載按鈕,我想生成多個PDF 目前我只能生成一個PDF生成與Weasyprint
我想是從Django的視圖生成兩個PDF當用戶點擊下載按鈕與weasyprint。
下面的代碼只生成一個PDF
def get(self, *args, **kwargs):
obj = self.get_object()
html_result = super(GenerateInvoicePDFView, self).get(*args,
**kwargs)
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="%s.pdf"' %
obj.name
weasyprint.HTML(string= html_result.getvalue()).write_pdf(response)
return response
這種反應應該產生兩個PDF,這可能嗎?請幫忙謝謝
您可以創建歸檔或者多頁的PDF文件,但響應 –
可能的複製沒有辦法回報多文件[用單個動作下載多個文件](https://stackoverflow.com/questions/2339440/download-multiple-files-with-a-single-action) – Pythonist