Skip to content
Browse files

[1.5.x] Fixed #19397 -- Crash on binary files in project templates.

Thanks gw 2012 at tnode com for the report.

Backport of baae4b8.
  • Loading branch information...
1 parent 1b93499 commit c9a47fb379cab4c0fe9be27c9924236e75327bd0 @aaugustin aaugustin committed
8 django/core/management/
@@ -8,8 +8,6 @@
import stat
import sys
import tempfile
-import codecs
from urllib.request import urlretrieve
except ImportError: # Python 2
@@ -156,12 +154,14 @@ def handle(self, app_or_project, name, target=None, **options):
# Only render the Python files, as we don't want to
# accidentally render Django templates files
- with, 'r', 'utf-8') as template_file:
+ with open(old_path, 'rb') as template_file:
content =
if filename.endswith(extensions) or filename in extra_files:
+ content = content.decode('utf-8')
template = Template(content)
content = template.render(context)
- with, 'w', 'utf-8') as new_file:
+ content = content.encode('utf-8')
+ with open(new_path, 'wb') as new_file:
if self.verbosity >= 2:
BIN  ...ressiontests/admin_scripts/custom_templates/project_template/ticket-19397-binary-file.ico
Binary file not shown

0 comments on commit c9a47fb

Please sign in to comment.
Something went wrong with that request. Please try again.