I
I
IvanOne2017-02-01 07:50:19
Django
IvanOne, 2017-02-01 07:50:19

How to get rid of the UnicodeEncodeError error?

Good afternoon! Made a store on django 1.10. I tightened the goods, but there is a problem on the site using sorl thumbnail. And when downloading goods, photos with Cyrillic in the title slip through. Result:

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)

File name IMG_3709_b.jpg
How to be?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question