Ticket #18091: 18091-startproject-non-ascii-templates.diff

File 18091-startproject-non-ascii-templates.diff, 667 bytes (added by Antti Kaihola, 12 years ago)

Avoid UnicodeDecodeError by encoding template engine output in UTF-8

  • django/core/management/templates.py

    diff --git a/django/core/management/templates.py b/django/core/management/templates.py
    index b2a1226..cf3d190 100644
    a b class TemplateCommand(BaseCommand):  
    156156                    content = template_file.read()
    157157                if filename.endswith(extensions) or filename in extra_files:
    158158                    template = Template(content)
    159                     content = template.render(context)
     159                    content = template.render(context).encode('UTF-8')
    160160                with open(new_path, 'w') as new_file:
    161161                    new_file.write(content)
    162162
Back to Top