[Answered ]-Django 1.4 – django.db.models.FileField.save(filename, file, save=True) produces error with non-ascii filename

2👍

You need to use .encode() to encode the string:

file.save(filename.encode('utf-8', 'ignore'), file, save=True) 
👤arocks

0👍

In your FileField definition the ‘upload_to’ argument might be like os.path.join(u’uploaded’, ‘files’, ‘%Y’, ‘%m’, ‘%d’)
(see the first u’uploaded’ started with u’) so all string will be of type unicode and this may help you.

👤Psion

Leave a comment