Skip to content

Instantly share code, notes, and snippets.

@lensraster
lensraster / fields.py
Last active August 29, 2015 14:10 — forked from yprez/fields.py
import base64
from django.core.files.base import ContentFile
from rest_framework import serializers
class Base64ImageField(serializers.ImageField):
def from_native(self, data):
if isinstance(data, basestring) and data.startswith('data:image'):
# base64 encoded image - decode