Jul
27
I’ve created a Django model using FileField:
class Car(models.Model): ... car = models.FileField(upload_to='upl/%Y/%m/%d') ...
I wanted to upload files named using polish characters (for example: “auto-żółw”). Unfortunately, Django erease polish letters (“auto-żółw” -> “auto-w”).
I’ve find out that the problem is in django.utils.text.get_valid_filename function.
After I’ve changed line:
return re.sub(r'[^-A-Za-z0-9_.]', '', s)
to
return re.sub('(?u)[^-.\w]', '', s)
Django accepts polish letters, too.
leave a reply