Opened 14 years ago
Closed 14 years ago
#14826 closed (invalid)
Accentuated filename upload
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | File uploads/storage | Version: | 1.2 |
Severity: | Keywords: | accent upload encode | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I encounter an Unhandled exception when I try to upload a file with accentuated characters in the filename.
This occur when I upload something in a FileField or ImageField, via the admin site.
There is no problem when I am using the django development server, but with Apache I have an UnicodeEncodeError.
Here is the traceback :
Traceback (most recent call last): File "/home/bioconvergence/modules/django/core/handlers/base.py", line 100, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/home/bioconvergence/modules/django/contrib/admin/options.py", line 239, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/home/bioconvergence/modules/django/utils/decorators.py", line 76, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/bioconvergence/modules/django/views/decorators/cache.py", line 69, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/home/bioconvergence/modules/django/contrib/admin/sites.py", line 190, in inner return view(request, *args, **kwargs) File "/home/bioconvergence/modules/django/utils/decorators.py", line 21, in _wrapper return decorator(bound_func)(*args, **kwargs) File "/home/bioconvergence/modules/django/utils/decorators.py", line 76, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/bioconvergence/modules/django/utils/decorators.py", line 17, in bound_func return func(self, *args2, **kwargs2) File "/home/bioconvergence/modules/django/db/transaction.py", line 299, in _commit_on_success res = func(*args, **kw) File "/home/bioconvergence/modules/django/contrib/admin/options.py", line 895, in change_view self.save_model(request, new_object, form, change=True) File "/home/bioconvergence/modules/django/contrib/admin/options.py", line 597, in save_model obj.save() File "/home/bioconvergence/modules/django/db/models/base.py", line 434, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/home/bioconvergence/modules/django/db/models/base.py", line 499, in save_base values = [(f, None, (raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks] File "/home/bioconvergence/modules/django/db/models/fields/files.py", line 255, in pre_save file.save(file.name, file, save=False) File "/home/bioconvergence/modules/django/db/models/fields/files.py", line 92, in save self.name = self.storage.save(name, content) File "/home/bioconvergence/modules/django/core/files/storage.py", line 47, in save name = self.get_available_name(name) File "/home/bioconvergence/bioconvergence/ficheEntreprise/storage.py", line 124, in get_available_name if self.exists(name): File "/home/bioconvergence/bioconvergence/ficheEntreprise/storage.py", line 91, in exists return os.path.exists(self.path(name)) File "/usr/languages/python/2.6/lib/python2.6/genericpath.py", line 18, in exists st = os.stat(path) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 66: ordinal not in range(128)
Note:
See TracTickets
for help on using tickets.
First "/home/bioconvergence/bioconvergence/ficheEntreprise/storage.py" is definitly not Django code.
Second, the "name" argument is unicode, so Django done it's part. Python will handle unicode file names on your filesystem, only if the your OS settings support it. Also see: http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi#AdditionalTweaking