[Django]-Unable to render PIL object base64 image on template

5👍

base64.b64encode(buffered.getvalue()) returns a byte class object. It needs to be converted to a string before passing it to a template. It can be done as follows:

img_str = base64.b64encode(buffered.getvalue()).decode('ascii')

Leave a comment