[Answer]-Django management command raises UnicodeEncodeError only when redirecting output to file

1👍

You can change the standard output of the script with UTF-8 encoded output :

import sys
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)

Or you can encode your strings before printing them:

print string_containing_unicode.encode('utf-8')

Leave a comment