Friday, March 2, 2012

Re: UnicodeEncodeError in file uploads

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPUQvMAAoJELGuljs/RfjIGjUH/Rqig6qWj144RN6L0vVrNDWB
ctv9t6YtfyOpfdWAF9CktKi+6F7RVB4+3YKmd3gJC9bI65+gsnMZ0oYb6NUbnciA
N3DZm/KjsPJHOb4N9dQ0BmTNs21X5LO8E+rABsumNKNKrO3NpeU3G8472VMEy6ly
VFoWB0nFEwaoAwLIi1aF5fD22SJKlg4IKC+wllO4xmfo9xP7E1A+o10UqcMqc5ka
cnpv1V2zsyz3hkWgiakJw8rf0gr406hd8O0jhXPp+iTkdfYsr/cGizPszWzYCTuB
RFxd6wP/f64Lcis9pQNgujAZfGz8UciHG6nvN0cDGJvNH8uFR0QlWzAQE46wPzY=
=z7RR
-----END PGP SIGNATURE-----
In some older group post I found a nice django-based solution: Using a
customized ImageField instance:

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)
data.name = slugify_name(data.name)
return data

No comments:

Post a Comment