Skip to content

Commit

Permalink
fixes .pdf template files when running with latest Django versions
Browse files Browse the repository at this point in the history
  • Loading branch information
smirolo committed Feb 23, 2024
1 parent f2bd26d commit 1b4eb0f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions extended_templates/backends/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,20 @@ def find_template(self, template_name, dirs=None, skip=None):
if skip is not None and origin in skip:
tried.append((origin, 'Skipped'))
continue
contents = None
try:
contents = loader.get_contents(origin)
except TemplateDoesNotExist:
tried.append((origin, 'Source does not exist'))
continue
else:
template = Template(
contents, origin, origin.template_name)
return template, template.origin
except UnicodeDecodeError:
# If we get this error it means the file exists;
# we just can't pass the mode to
# `django.template.loaders.filesystem.Loader`
pass
template = Template(
contents, origin, origin.template_name)
return template, template.origin
else:
# This code is there to support Django 1.8 only.
try:
Expand Down

0 comments on commit 1b4eb0f

Please sign in to comment.