django-imagekit
django-imagekit copied to clipboard
UnicodeEncodeError Exception Value: 'ascii' codec can't encode character u'\xf3' in position 58: ordinal not in range(128)
Hi Guys, thanks for this awsome and helpfull module,
The problem its really simple that generates an error when images have accents, something very usual in spanish, and raises this error about unicode encode error, i guess that the new name will have the accent like this "nam\f3" or something.
i know django have something call smart_str and smart_unicode (from django.utils.encoding import smart_str, smart_unicode) that can be helpfull
"UnicodeEncodeError
Exception Value:
'ascii' codec can't encode character u'\xf3' in position 58: ordinal not in range(128)"
/usr/local/lib/python2.7/dist-packages/imagekit/models/fields/files.py in save
return super(ProcessedImageFieldFile, self).save(new_name, content, save) ...
▼ Local vars
Variable Value
new_name
u'Capacitaci\xf3n of administrativa 023.JPG'
name
u'Capacitaci\xf3n of administrativa 023.JPG'
self
<ProcessedImageFieldFile: Capacitación of administrativa 023.JPG>
filename
u'Capacitaci\xf3n of administrativa 023'
content
<File: /tmp/tmpDaFrz8>
ext
u'.JPG'
save
False
spec
<imagekit.specs.DynamicSpec object at 0x7ff21a6fe610>
It's very strange. I tried with files with unicode characters in the name and everything works as expected.
Can you show us the whole traceback?
@pulsarav I see that it was long time ago but we have no response from you. Did you managed to resolve the problem?
I have the same issue ;(
CACHE/images/core/criancasanimais/195a637a0d90243f296307fecb961e4b.jpg
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/webapps/eugostode/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/webapps/eugostode/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/webapps/eugostode/env/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/webapps/eugostode/env/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/webapps/eugostode/env/lib/python3.5/site-packages/imagekit/management/commands/generateimages.py", line 28, in handle
self.stdout.write(' %s\n' % image_file.name)
File "/home/webapps/eugostode/env/lib/python3.5/site-packages/django/core/management/base.py", line 110, in write
self._out.write(force_str(style_func(msg)))
I am working with Pt-BR
thanks
@Leeaandrob actually your issue looks different because it is caused in generateimages
management command when try to output to the stdout which image was just generated. The original issue was related to storing the file on the file system.
Your issue looks like some misconfiguration of the locale but I'm not absolutely sure. I need to investigate it further.