mySerializerWithJSON.py 380 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from backend_app.fields import JSONField
Florent Chehab's avatar
Florent Chehab committed
2 3 4 5 6 7 8 9 10 11 12
from rest_framework import serializers

field_mapping = serializers.ModelSerializer.serializer_field_mapping
field_mapping[JSONField] = serializers.JSONField


class MySerializerWithJSON(serializers.ModelSerializer):
    """
    Simple class to add support for custom JSONField support
    """
    serializer_field_mapping = field_mapping