Guest User

Untitled

a guest
Sep 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. def render_ticket_view(request):
  2. template_path = 'ticket.html'
  3. context = {
  4. ...
  5. }
  6.  
  7. response = PDFTemplateResponse(
  8. request=request,
  9. template=template_path,
  10. filename='file.pdf',
  11. context=context,
  12. cmd_options={'load-error-handling': 'ignore'}
  13. )
  14.  
  15. batch = TicketBatch.objects.create()
  16.  
  17. batch.document.save(
  18. "{}-{}.pdf".format(event.name.replace(" ", "_"), batch.id),
  19. response.rendered_content
  20. )
  21.  
  22. batch.save()
  23.  
  24. return response
Add Comment
Please, Sign In to add comment