Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating PDFs with django (wkhtmltopdf)
    primarykey
    data
    text
    <p>Could someone please provide me with a comprehensive example of how to get a <code>view</code> in <code>django</code> to return a <code>PDF</code> using <code>wkhtmltopdf</code>. There are limited number of examples that come with <code>django-wkhtmltopdf</code> and they presume a level of knowledge I just don't have. I have looked through the source code but I can't make heads or tails of how to use it (for example whats the difference between <code>PDFTemplateView</code> and <code>PDFTemplateResponse</code>?!?)</p> <p>I would be very grateful for any help.</p> <p><em>BTW(I'm using templates for the header and footer as well)</em></p> <p><strong>EDIT</strong></p> <pre><code>def some_view(request,sID): something = get_object_or_404(Something,id=sID) return render_to_response('something.html', {'something':something}, context_instance=RequestContext(request)) </code></pre> <p>How would I get the following simple view to provide me with a <code>pdf</code> instead of an <code>html</code> file?</p> <p><strong>EDIT 2</strong></p> <p>I am currently playing around with:</p> <pre><code>def pdf_view(request,sID): template = 'pdf.html' something = get_object_or_404(Something,id=sID) context = { 'something' : Something, 'object_for_header_and_footer': something.object_for_header_and_footer, } cmd_options = settings.WKHTMLTOPDF_CMD_OPTIONS return PDFTemplateResponse(request=request, context=context, template=template, filename='something', header_template='header.html', footer_template='footer.html', cmd_options=cmd_options) </code></pre> <p>but I am getting <code>'str' object has no attribute 'update'</code> in <code>/usr/local/lib/python2.7/dist-packages/wkhtmltopdf/utils.py in wkhtmltopdf, line 74</code>. I don't know whether to starting hacking wkhtmltopdf?!?!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload