diff options
author | Simon Law <simon.law@ecometrica.com> | 2012-07-24 16:29:30 -0400 |
---|---|---|
committer | Simon Law <simon.law@ecometrica.com> | 2012-07-24 16:29:30 -0400 |
commit | a6f0a53702a940bf055dadb3bf558aea49c6d862 (patch) | |
tree | d1a08afbf8a02e19a304a2f84c047b217b1e8c21 | |
parent | 566738a2f151918c00c522b3f2c742f2faf185dc (diff) | |
download | django-wkhtmltopdf-a6f0a53702a940bf055dadb3bf558aea49c6d862.tar.gz django-wkhtmltopdf-a6f0a53702a940bf055dadb3bf558aea49c6d862.tar.bz2 django-wkhtmltopdf-a6f0a53702a940bf055dadb3bf558aea49c6d862.zip |
Cleanups and documentation.
-rw-r--r-- | wkhtmltopdf/views.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py index bd1da13..c337b6c 100644 --- a/wkhtmltopdf/views.py +++ b/wkhtmltopdf/views.py @@ -1,6 +1,5 @@ from __future__ import absolute_import -import os from re import compile from tempfile import NamedTemporaryFile import warnings @@ -8,7 +7,6 @@ import warnings from django.conf import settings from django.contrib.sites.models import Site from django.http import HttpResponse -from django.template.context import RequestContext from django.template.response import TemplateResponse from django.views.generic import TemplateView @@ -16,6 +14,8 @@ from .utils import (content_disposition_filename, wkhtmltopdf) class PDFResponse(HttpResponse): + """HttpResponse that sets the headers for PDF output.""" + def __init__(self, content, mimetype=None, status=200, content_type=None, filename=None, *args, **kwargs): @@ -134,10 +134,17 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse): class PDFTemplateView(TemplateView): + """Class-based view for HTML templates rendered to PDF.""" + + # Filename for downloaded PDF. If None, the response is inline. filename = 'rendered_pdf.pdf' - footer_template = None + + # Filenames for the content, header, and footer templates. + template_name = None header_template = None + footer_template = None + # TemplateResponse classes for PDF and HTML response_class = PDFTemplateResponse html_response_class = TemplateResponse |