Specify encoding for templates in case it's not the default

This commit is contained in:
Ben Sturmfels 2024-03-22 10:10:57 +11:00
parent fe64a26a72
commit da121e5eb4
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -48,7 +48,7 @@ def index(request, *args, **kwargs):
pass pass
# These template are intentionally not in the template loader path, so # These template are intentionally not in the template loader path, so
# we open them directly, rather than using the template loader. # we open them directly, rather than using the template loader.
with open(full_path) as t: with open(full_path, encoding='utf-8') as t:
template = Template(t.read()) template = Template(t.read())
context = RequestContext(request, kwargs) context = RequestContext(request, kwargs)
return HttpResponse(template.render(context)) return HttpResponse(template.render(context))