В приложении Django пользователь загружает изображение, используя форму. Я не знаю, почему. Я могу загружать файлы с акцентированными символами по имени. Исключение составляет нижеИсключение UnicodeEncodeError при загрузке изображения
File "pathto/python2.7/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs) File "/pathto/python2.7/django/contrib/auth/decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "/pathto/views.py", line 75, in upload_image obj = form.save(request.user) File "/form.py", line 88, in save obj.save() File "/pahtto/python2.7/django/db/models/base.py", line 460, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/pathto/python2.7/django/db/models/base.py", line 543, in save_base for f in meta.local_fields if not isinstance(f, AutoField)] File "/pathto/lib/python2.7/django/db/models/fields/files.py", line 255, in pre_save file.save(file.name, file, save=False) File "/pathto/extrantool.py", line 96, in save super(ImageWithThumbsFieldFile, self).save(name, content, save) File "/pathto/python2.7/django/db/models/fields/files.py", line 92, in save self.name = self.storage.save(name, content) File "/pathto/python2.7/django/core/files/storage.py", line 48, in save name = self.get_available_name(name) File "/pathto/python2.7/django/core/files/storage.py", line 74, in get_available_name while self.exists(name): File "/pathto/python2.7/django/core/files/storage.py", line 218, in exists return os.path.exists(self.path(name)) File "/usr/local/lib/python2.7/genericpath.py", line 18, in exists os.stat(path) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 66: ordinal not in range(128)
Это сообщение не поступало из PostgreSQL, поэтому посмотрите на другие части вашего стека. – kgrittn
Нам нужно будет увидеть вашу модель и значения, чтобы выяснить, где проблема. Похоже, что есть имя не-ascii в имени файла. – Brandon
У вас есть пользовательский обработчик 'upload_to'? Работает ли он с unicode полностью? – ilvar