From 83ee4981f05046c90fea3b34332460aa06eb9053 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Fri, 9 Mar 2012 10:54:11 +0000 Subject: Fixed remote images in pdf If there's no context_instance (which seems to be the common case), make a Requestcontext and use that. --- wkhtmltopdf/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'wkhtmltopdf') diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py index b8e31d4..b15d7be 100644 --- a/wkhtmltopdf/views.py +++ b/wkhtmltopdf/views.py @@ -3,6 +3,7 @@ from re import compile from django.conf import settings from django.contrib.sites.models import Site +from django.template.context import RequestContext from django.template.response import HttpResponse from django.views.generic import TemplateView @@ -37,7 +38,10 @@ class PDFTemplateView(TemplateView): if request.GET.get('as', '') == 'html': return super(PDFTemplateView, self).get(request, *args, **kwargs) - self.context_instance = context_instance + if context_instance: + self.context_instance = context_instance + else: + self.context_instance = RequestContext(request, self.get_context_data(**kwargs)) page_path = template_to_temp_file(self.get_template_names(), self.get_context_data(), self.context_instance) pdf_kwargs = self.get_pdf_kwargs() @@ -80,4 +84,4 @@ class PdfTemplateView(PDFTemplateView): #TODO: Remove this in v1.0 def as_view(cls, **initkwargs): warning = '''PdfTemplateView is deprecated in favour of PDFTemplateView. It will be removed in version 1.''' raise PendingDeprecationWarning(warning) - return super(PdfTemplateView, cls).as_view(**initkwargs) \ No newline at end of file + return super(PdfTemplateView, cls).as_view(**initkwargs) -- cgit v1.2.3