1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #18091 -- Non-ASCII templates break django-admin.py startproject --template=TEMPLATE.

Thanks to Claude Huchet and Tomáš Ehrlich for the patch.
This commit is contained in:
Florian Apolloner
2012-08-28 23:22:06 +02:00
parent 20012b961e
commit 3afb5916b2
3 changed files with 19 additions and 2 deletions

View File

@@ -8,6 +8,8 @@ import shutil
import stat
import sys
import tempfile
import codecs
try:
from urllib.request import urlretrieve
except ImportError: # Python 2
@@ -154,12 +156,12 @@ class TemplateCommand(BaseCommand):
# Only render the Python files, as we don't want to
# accidentally render Django templates files
with open(old_path, 'r') as template_file:
with codecs.open(old_path, 'r', 'utf-8') as template_file:
content = template_file.read()
if filename.endswith(extensions) or filename in extra_files:
template = Template(content)
content = template.render(context)
with open(new_path, 'w') as new_file:
with codecs.open(new_path, 'w', 'utf-8') as new_file:
new_file.write(content)
if self.verbosity >= 2: