Pozwól Django Imagefield zaakceptuj bazę 64 obraz

pip install pillow
import base64
import io
from PIL import Image
from django.core.files.uploadedfile import InMemoryUploadedFile

def decodeDesignImage(data):
    try:
        data = base64.b64decode(data.encode('UTF-8'))
        buf = io.BytesIO(data)
        img = Image.open(buf)
        return img
    except:
        return None
   	img = decodeDesignImage(data)
    img_io = io.BytesIO()
    img.save(img_io, format='JPEG')
    design.image = InMemoryUploadedFile(img_io, field_name=None, name=token+".jpg", content_type='image/jpeg', size=img_io.tell, charset=None)
    design.save()
Elias Imokhai