Opened 8 years ago

Closed 8 years ago

#14826 closed (invalid)

Accentuated filename upload

Reported by: Adrien <ad@…> 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


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/", line 100, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/home/bioconvergence/modules/django/contrib/admin/", line 239, in wrapper
   return self.admin_site.admin_view(view)(*args, **kwargs)

 File "/home/bioconvergence/modules/django/utils/", line 76, in _wrapped_view
   response = view_func(request, *args, **kwargs)

 File "/home/bioconvergence/modules/django/views/decorators/", line 69, in _wrapped_view_func
   response = view_func(request, *args, **kwargs)

 File "/home/bioconvergence/modules/django/contrib/admin/", line 190, in inner
   return view(request, *args, **kwargs)

 File "/home/bioconvergence/modules/django/utils/", line 21, in _wrapper
   return decorator(bound_func)(*args, **kwargs)

 File "/home/bioconvergence/modules/django/utils/", line 76, in _wrapped_view
   response = view_func(request, *args, **kwargs)

 File "/home/bioconvergence/modules/django/utils/", line 17, in bound_func
   return func(self, *args2, **kwargs2)

 File "/home/bioconvergence/modules/django/db/", line 299, in _commit_on_success
   res = func(*args, **kw)

 File "/home/bioconvergence/modules/django/contrib/admin/", line 895, in change_view
   self.save_model(request, new_object, form, change=True)

 File "/home/bioconvergence/modules/django/contrib/admin/", line 597, in save_model

 File "/home/bioconvergence/modules/django/db/models/", line 434, in save
   self.save_base(using=using, force_insert=force_insert, force_update=force_update)

 File "/home/bioconvergence/modules/django/db/models/", 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/", line 255, in pre_save, file, save=False)

 File "/home/bioconvergence/modules/django/db/models/fields/", line 92, in save =, content)

 File "/home/bioconvergence/modules/django/core/files/", line 47, in save
   name = self.get_available_name(name)

 File "/home/bioconvergence/bioconvergence/ficheEntreprise/", line 124, in get_available_name
   if self.exists(name):

 File "/home/bioconvergence/bioconvergence/ficheEntreprise/", line 91, in exists
   return os.path.exists(self.path(name))

 File "/usr/languages/python/2.6/lib/python2.6/", 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)

Change History (1)

comment:1 Changed 8 years ago by Łukasz Rekucki

Resolution: invalid
Status: newclosed

First "/home/bioconvergence/bioconvergence/ficheEntreprise/" 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:

Note: See TracTickets for help on using tickets.
Back to Top