django-avatar
django-avatar copied to clipboard
Unicode characters in file names don't work
Noticed this when a user tried uploading an avatar with 'ä' in his avatar's filename.
Traceback (most recent call last):
File "/srv/styleloving/venv/lib/python2.6/site-packages/django/core/handlers/base.py", line 100, in get_response response = callback(request, _callback_args, *_callback_kwargs)
File "/srv/styleloving/venv/lib/python2.6/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view return view_func(request, _args, *_kwargs)
File "/srv/styleloving/venv/lib/python2.6/site-packages/avatar/views.py", line 63, in change new_file = avatar.avatar.storage.save(path, request.FILES['avatar'])
File "/srv/styleloving/venv/lib/python2.6/site-packages/django/core/files/storage.py", line 47, in save name = self.get_available_name(name)
File "/srv/styleloving/venv/lib/python2.6/site-packages/django/core/files/storage.py", line 73, in get_available_name while self.exists(name):
File "/srv/styleloving/venv/lib/python2.6/site-packages/django/core/files/storage.py", line 196, in exists return os.path.exists(self.path(name))
File "/usr/lib/python2.6/genericpath.py", line 18, in exists st = os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 53: ordinal not in range(128)
Not sure if you still use this django-avatar, it's actually related to your environment settings. I post the link here so that others with the same problem can fix it.
https://code.djangoproject.com/ticket/10905
This is not a django-avatar issue.