mySerializerWithJSON.py 381 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
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
    """
12

Florent Chehab's avatar
Florent Chehab committed
13
    serializer_field_mapping = field_mapping