def download_cv_pdf(request, cv_id):
cv = get_object_or_404(CV, pk=cv_id)
response = HttpResponse(content_type="application/pdf")
response["Content-Disposition"] = "attachment; filename=%s_%s.pdf" % (cv.first_name, cv.last_name)
html = render_to_string("cv/cv_pdf.html", {
"cv": cv,
"MEDIA_ROOT": settings.MEDIA_ROOT,
"STATIC_ROOT": settings.STATIC_ROOT,
})
pdf = pisa.pisaDocument(
StringIO(html.encode("UTF-8")),
response,
encoding="UTF-8",
)
return response
views.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录