#27171: #7201 Change 'unicode_literals' in TemplateCommand, change admin and view templates -------------------------------------+------------------------------------- Reporter: baterson | Owner: nobody Type: | Status: new Cleanup/optimization | Component: Template system | Version: 1.10 Severity: Normal | Keywords: admin_scripts, | TemplateCommand Triage Stage: Unreviewed | Has patch: 1 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- When you run `manage.py startapp` with python2, TemplateCommand context add `from __future__ import unicode literals` at the top. If you using non askii symbols on python2, like cyrillic alphabet, you still have an error 'SyntaxError: Non-ASCII character' because encoding not specified. Also admin and views templates needed unicode_literals too. For example, when you put some comments in non askii or raise error message. Here is changes of TemplateCommand Context:
{{{ index 8c38f3f..b2ff964 100644 --- a/django/conf/app_template/admin.py-tpl +++ b/django/conf/app_template/admin.py-tpl @@ -1,3 +1,3 @@ -from django.contrib import admin +{{ unicode_literals }}from django.contrib import admin # Register your models here. diff --git a/django/conf/app_template/views.py-tpl b/django/conf/app_template/views.py-tpl index 91ea44a..61821e7 100644 --- a/django/conf/app_template/views.py-tpl +++ b/django/conf/app_template/views.py-tpl @@ -1,3 +1,3 @@ -from django.shortcuts import render +{{ unicode_literals }}from django.shortcuts import render # Create your views here. diff --git a/django/core/management/templates.py b/django/core/management/templates.py index df522e8..fd957fb 100644 --- a/django/core/management/templates.py +++ b/django/core/management/templates.py @@ -114,7 +114,8 @@ class TemplateCommand(BaseCommand): camel_case_name: camel_case_value, 'docs_version': get_docs_version(), 'django_version': django.__version__, - 'unicode_literals': '' if six.PY3 else 'from __future__ import unicode_literals\n\n', + 'unicode_literals': '' if six.PY3 else '# -*- coding: utf-8 -*-\n' + 'from __future__ import unicode_literals\n\n', }), autoescape=False) # Setup a stub settings environment for template rendering }}} -- Ticket URL: <https://code.djangoproject.com/ticket/27171> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.d40f03c868cefccbd57faecca9a36f86%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.