AIM
I am attempting to encode a folium
choropleth as StringIO
. I am basing my answer of a related query. I have checked the answers here and here.
ERROR
AttributeError: 'bytes' object has no attribute 'encode'
CODE
views.py
def get_choropleth(self, request):
# make choropleth ('m')
html_string = m.get_root().render()
f = StringIO(html_string)
choropleth = base64.b64decode(f.read())
choropleth = choropleth.encode('utf8') # causing error
return {'choropleth':choropleth}