2
Your payload is a unicode
instance (note that Django strives to only use unicode
internally) while it should be str
instance. It’s your responsability to pass a (preferably properly encoded) str
. Which is quite easy FWIW:
# I assume you use utf-8 everywhere
text_content = plaintext.render(d).encode("utf-8")
html_content = htmly.render(d).encode("utf-8")
Source:stackexchange.com