Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. statistics_string = render_to_string('statistics/statistics_pdf.html', context) html = HTML(string=statistics_string, base_url=request.build_absolute_uri()) html.write_pdf(target='/tmp/statistics.pdf', stylesheets=[CSS(STATIC_ROOT+'/css/index-style.css')]) fs = FileSystemStorage('/tmp') with fs.open('statistics.pdf') as pdf: response = HttpResponse(pdf, content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="statistics.pdf"' return response return response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement