I need to store bitmap representation of an image in my code, so I did this in my model
logo = models.BinaryField(blank=True, null=True)
now Django-rest doesn't have a serializer field for BinaryField. If I create my own serializer field for this, how would I be able to use it in my code ? For example, if I create something like
class MyBinaryField(serializers.Field):
def to_representation(self, obj):
return base64.b64decode(obj)
def to_internal_value(self, data):
return base64.encodestring(data)
How can I plug this mapping of models.BinaryField and MyBinaryField in my serializer. I know there is a default serializer_field_mapping map available and I can override it, but I want to use existing serializer_field_mapping as well. How can I insert my new entry into existing serializer_field_mapping or declare new values in current map ?