2
我使用django-wkhtmltopdf生成PDF報告。該報告然後下載到客戶端機器。我想將其副本留在服務器上。我如何將pdf直接保存到服務器上。Django:將pdf保存到服務器而不是客戶端
我的繼承人PDF查看:
class PDFView(DetailView):
template = 'pdf_reports/report.html'
today = datetime.now()
context = {'today': today.strftime('%d %b %Y')}
model = Model
def get(self, request, *args, **kwargs):
self.context['model'] = self.get_object()
response=PDFTemplateResponse(request=request,
template=self.template,
filename ="report.pdf",
context=self.context,
show_content_in_browser=False,
cmd_options={'margin-top': 0,
'margin-left': 0,
'margin-right': 0}
)
return response
我想像你保存響應的方式與你[fileupload]相同(https://docs.djangoproject.com/en/1.8/topics/http/file-upload s /#basic-file-uploads)我還沒試過這個.. – Sayse