diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index d514c84..69514c4 100644
|
a
|
b
|
from os import path
|
| 14 | 14 | import django |
| 15 | 15 | from django.template import Template, Context |
| 16 | 16 | from django.utils import archive |
| | 17 | from django.utils import six |
| 17 | 18 | from django.utils.six.moves.urllib.request import urlretrieve |
| 18 | 19 | from django.utils._os import rmtree_errorhandler |
| 19 | 20 | from django.core.management.base import BaseCommand, CommandError |
| … |
… |
class TemplateCommand(BaseCommand):
|
| 149 | 150 | |
| 150 | 151 | # Only render the Python files, as we don't want to |
| 151 | 152 | # accidentally render Django templates files |
| 152 | | with open(old_path, 'rb') as template_file: |
| 153 | | content = template_file.read() |
| | 153 | render_file = False |
| 154 | 154 | if filename.endswith(extensions) or filename in extra_files: |
| 155 | | content = content.decode('utf-8') |
| | 155 | render_file = True |
| | 156 | with open(old_path, 'r%s' % ('' if render_file else 'b')) as template_file: |
| | 157 | content = template_file.read() |
| | 158 | if render_file: |
| | 159 | if six.PY2: |
| | 160 | content = content.decode('utf-8') |
| 156 | 161 | template = Template(content) |
| 157 | 162 | content = template.render(context) |
| 158 | | content = content.encode('utf-8') |
| 159 | | with open(new_path, 'wb') as new_file: |
| | 163 | if six.PY2: |
| | 164 | content = content.encode('utf-8') |
| | 165 | with open(new_path, 'w%s' % ('' if render_file else 'b')) as new_file: |
| 160 | 166 | new_file.write(content) |
| 161 | 167 | |
| 162 | 168 | if self.verbosity >= 2: |