Взял сервер на облаке, поставил джангу.
Когда код доходит до get_template,
Джанго выдаёт ошибку: UnicodeEncodeError at /
'ascii' codec can't encode characters in position 25-29: ordinal not in range(128)
Использую python3.4.2, и Джанго 1.7.3
Проверил файлы, оказалось, что все английские имена в ascii, русские в utf-8.
Почему английские в ascii - вообще непонятно.
Настройка локали на сервере:
$locale
LANG=ru_RU.utf8
LANGUAGE=
LC_CTYPE="ru_RU.utf8"
LC_NUMERIC="ru_RU.utf8"
LC_TIME="ru_RU.utf8"
LC_COLLATE="ru_RU.utf8"
LC_MONETARY="ru_RU.utf8"
LC_MESSAGES="ru_RU.utf8"
LC_PAPER="ru_RU.utf8"
LC_NAME="ru_RU.utf8"
LC_ADDRESS="ru_RU.utf8"
LC_TELEPHONE="ru_RU.utf8"
LC_MEASUREMENT="ru_RU.utf8"
LC_IDENTIFICATION="ru_RU.utf8"
LC_ALL=
$locale -a
C
C.UTF-8
en_US.utf8
POSIX
ru_RU.koi8r
ru_RU.utf8
ru_UA.utf8
И ещё тест:
Python 3.4.2 (default, Oct 8 2014, 13:18:07)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
import sys
>>>print('sys.getdefaultencoding(): ' + sys.getdefaultencoding())
sys.getdefaultencoding(): utf-8
>>>print('sys.getfilesystemencoding(): ' + sys.getfilesystemencoding())
sys.getfilesystemencoding(): utf-8
Трэйсбэк самой ошибки:
Environment:
Request Method: GET
Request URL: http://
Django Version: 1.7.3
Python Version: 3.4.2
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/python3/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/python3/orion/orion/views.py" in карта
13. сырой_шаблон = get_template("карта.html")
File "/python3/lib/python3.4/site-packages/django/template/loader.py" in get_template
144. template, origin = find_template(template_name, dirs)
File "/python3/lib/python3.4/site-packages/django/template/loader.py" in find_template
132. source, display_name = loader(name, dirs)
File "/python3/lib/python3.4/site-packages/django/template/loader.py" in __call__
44. return self.load_template(template_name, template_dirs)
File "/python3/lib/python3.4/site-packages/django/template/loader.py" in load_template
47. source, display_name = self.load_template_source(template_name, template_dirs)
File "/python3/lib/python3.4/site-packages/django/template/loaders/filesystem.py" in load_template_source
38. with open(filepath, 'rb') as fp:
Exception Type: UnicodeEncodeError at /
Exception Value: 'ascii' codec can't encode characters in position 25-29: ordinal not in range(128)
В чём может быть проблема?
Updated 23 Jan. 2015, 13:04 by Michael.