4👍
✅
Solved the problem!
The ContentFile is a subclass of cStringIO.StringIO – which deals with ASCII encoded files. The string therefore needs to be encoded as ASCII as everything in django is UTF8 by default
cf = ContentFile(rendered.encode('ascii'))
Source:stackexchange.com