Rectangle 27 0

The general way to handle this may be to write a custom upload handler and tell Django to use it. But I've never done this, so I'm not sure.

But a simple approach would be to just wrap the underlying file object. (If you use TextIOWrapper instead of StringIO you shouldn't need to worry about the overhead.)

from io import TextIOWrapper

f = form.files['file']
text_f = TextIOWrapper(f.file, encoding='utf-8')

python - Django: uploaded file is binary. Is it possible to change to ...

python django unicode