Skip to content

Instantly share code, notes, and snippets.

amirasaran /
Last active June 11, 2017 10:46 — forked from yprez/
Django rest framework - Base64 image field
import base64
from django.core.files.base import ContentFile
from rest_framework import serializers
class Base64ImageField(serializers.ImageField):
def to_internal_value(self, data):
if isinstance(data, basestring) and data.startswith('data:image'):
# base64 encoded image - decode