Я развертываю приложение django на Docker. Все отлично работает в локальной среде (Windows 10, django 2.2.10, Pyhon 3.7).
Howerver, при развертывании на Docker я получил UnicodeDecodeError. Вот трекбек:
Traceback (most recent call last):
File "run_uvicorn.py", line 26, in <module>
main()
File "run_uvicorn.py", line 14, in main
configurations.setup()
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/configurations/__init__.py", line 31, in setup
_setup()
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/configurations/__init__.py", line 17, in _setup
django.setup()
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/contrib/auth/models.py", line 95, in <module>
class Group(models.Model):
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/db/models/base.py", line 156, in __new__
new_class.add_to_class(obj_name, obj)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/db/models/base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/db/models/fields/related.py", line 1588, in contribute_to_class
self.remote_field.through = create_many_to_many_intermediary_model(self, cls)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/db/models/fields/related.py", line 1057, in create_many_to_many_intermediary_model
'verbose_name': _('%(from)s-%(to)s relationship') % {'from': from_, 'to': to},
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/utils/functional.py", line 192, in __mod__
return str(self) % rhs
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/utils/functional.py", line 156, in __text_cast
return func(*self.__args, **self.__kw)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/utils/translation/__init__.py", line 79, in gettext
return _trans.gettext(message)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/utils/translation/trans_real.py", line 285, in gettext
_default = _default or translation(settings.LANGUAGE_CODE)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/utils/translation/trans_real.py", line 198, in translation
_translations[language] = DjangoTranslation(language)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/utils/translation/trans_real.py", line 97, in __init__
self._add_installed_apps_translations()
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/utils/translation/trans_real.py", line 145, in _add_installed_apps_translations
translation = self._new_gnu_trans(localedir)
File "/home/ec2-user/.local/share/virtualenvs/spots-6d0OxoJW/lib/python3.7/site-packages/django/utils/translation/trans_real.py", line 123, in _new_gnu_trans
fallback=use_null_fallback,
File "/home/ec2-user/.pyenv/versions/3.7.6/lib/python3.7/gettext.py", line 533, in translation
t = _translations.setdefault(key, class_(fp))
File "/home/ec2-user/.pyenv/versions/3.7.6/lib/python3.7/gettext.py", line 260, in __init__
self._parse(fp)
File "/home/ec2-user/.pyenv/versions/3.7.6/lib/python3.7/gettext.py", line 421, in _parse
catalog[str(msg, charset)] = str(tmsg, charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)
django настройки:
LANGUAGE_CODE = "zh-hans"
, установленный в en-us, исправит, но я должен использовать zh-hans.