﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17816	UnicodeEncodeError in Image- and FileFields	andi@…	nobody	"Uploading files (and images) containing non-ASCII characters (e.g. German umlauts) with a form containing an ImageField or FileField causes a UnicodeEncodeError on recent versions of Ubuntu servers. Curiously this does not happen on the development-server or older Debian 5 servers.

In order to avoid this error and non-ASCII characters in URLs I'd like to suggest a built-in (optional) conversion of the filename in the Image- and/or FileField class (or corresponding base class).

{{{
class MyImageField(ImageField):

    def __init__(self, *args, **kwargs):
        super(MyImageField, self).__init__(*args, **kwargs)

    def clean(self, *args, **kwargs):
        data = super(MyImageField, self).clean(*args, **kwargs)
        filename = os.path.splitext(data.name)
        data.name = unicode(data.name)
        if len(filename[1]):
            data.name += u'.'+slugify(filename[1])
        return data
}}}
where slugify is e.g. the slugify function from django.template.defaultfilters
"	Cleanup/optimization	closed	Forms	1.3	Normal	invalid		anssi.kaariainen@…	Unreviewed	0	0	0	0	0	0
