mySerializerWithJSON.py 376 Bytes
Newer Older
1
from backend.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