diff options
author | James Turnbull <james@incuna.com> | 2012-03-09 10:54:11 +0000 |
---|---|---|
committer | James Turnbull <james@incuna.com> | 2012-03-09 10:54:11 +0000 |
commit | 83ee4981f05046c90fea3b34332460aa06eb9053 (patch) | |
tree | a48496594473ce60d04d49793a7b21c3fca5e17c /wkhtmltopdf | |
parent | c71fc06f47c16cbee56167418eeb31b7150079fc (diff) | |
download | django-wkhtmltopdf-83ee4981f05046c90fea3b34332460aa06eb9053.tar.gz django-wkhtmltopdf-83ee4981f05046c90fea3b34332460aa06eb9053.tar.bz2 django-wkhtmltopdf-83ee4981f05046c90fea3b34332460aa06eb9053.zip |
Fixed remote images in pdf
If there's no context_instance (which seems to be the common case), make a Requestcontext and use that.
Diffstat (limited to 'wkhtmltopdf')
-rw-r--r-- | wkhtmltopdf/views.py | 8 |
1 files changed, 6 insertions, 2 deletions
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) |