@IvanOne

Как избавится от ошибки UnicodeEncodeError?

День добрый! Сделал магазин на django 1.10. Затянул товары, но есть проблема на сайте юзается sorl thumbnail. И при закачке товаров проскакивают фото с кириллицей в названии. Результат:
Traceback:

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
  217.                 response = self.process_exception_by_middleware(e, request)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
  215.                 response = response.render()

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/response.py" in render
  109.             self.content = self.rendered_content

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/response.py" in rendered_content
  86.         content = template.render(context, self._request)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in render
  208.                     return self._render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/loader_tags.py" in render
  174.         return compiled_parent._render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/loader_tags.py" in render
  70.                 result = block.nodelist.render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/defaulttags.py" in render
  209.                     nodelist.append(node.render_annotated(context))

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/sorl/thumbnail/templatetags/thumbnail.py" in render
  59.             return self._render(context)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/sorl/thumbnail/templatetags/thumbnail.py" in _render
  137.         thumbnail = get_thumbnail(file_, geometry, **options)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/sorl/thumbnail/shortcuts.py" in get_thumbnail
  8.     return default.backend.get_thumbnail(file_, geometry_string, **options)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/sorl/thumbnail/base.py" in get_thumbnail
  103.                 source_image = default.engine.get_image(source)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/sorl/thumbnail/engines/pil_engine.py" in get_image
  48.         buffer = BufferIO(source.read())

File "/home/f/fh792387/.local/lib/python3.4/site-packages/sorl/thumbnail/images.py" in read
  140.         return self.storage.open(self.name).read()

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/core/files/storage.py" in open
  38.         return self._open(name, mode)

File "/home/f/fh792387/.local/lib/python3.4/site-packages/django/core/files/storage.py" in _open
  300.         return File(open(self.path(name), mode))

Exception Type: UnicodeEncodeError at /
Exception Value: 'ascii' codec can't encode character '\u0431' in position 60: ordinal not in range(128)

Имя файла IMG_3709_б.jpg
Как быть?
  • Вопрос задан
  • 178 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы