From 53e027b229d5f437026490f3fad37480294301d7 Mon Sep 17 00:00:00 2001 From: apmorton Date: Mon, 7 Oct 2013 11:43:21 -0400 Subject: [PATCH] Fix windows line endings in offline compress django itself always opens template files in binary mode, which causes an issue with offline compression on windows when template files contain windows line endings. --- compressor/management/commands/compress.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compressor/management/commands/compress.py b/compressor/management/commands/compress.py index c106e63..a7efaca 100644 --- a/compressor/management/commands/compress.py +++ b/compressor/management/commands/compress.py @@ -219,8 +219,8 @@ class Command(NoArgsCommand): compressor_nodes = SortedDict() for template_name in templates: try: - with io.open(template_name, encoding=settings.FILE_CHARSET) as file: - template = Template(file.read()) + with io.open(template_name, mode='rb') as file: + template = Template(file.read().decode(settings.FILE_CHARSET)) except IOError: # unreadable file -> ignore if verbosity > 0: log.write("Unreadable template at: %s\n" % template_name)