Save Base64 String into Django ImageField
问题 Im doing an application that uses Django in server-side. Im trying to do that: import uuid from base64 import b64decode from django.core.files.base import ContentFile @staticmethod def add_photo(user, person, image_base64): photo = DatabasePersonPhoto() photo.user = user photo.person = person image_data = b64decode(image_base64) image_name = str(uuid.uuid4())+".jpg" photo.image = ContentFile(image_data, image_name) photo.save() return photo This is my Base64 String: data:image/jpeg;base64,/9j