Python rest_framework.serializers 模块,JSONField() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用rest_framework.serializers.JSONField()

项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_json_convert_jsonstring():
    assert_conversion(serializers.JSONField, graphene.types.json.JSONString)
项目:drf_openapi    作者:limdauto    | 项目源码 | 文件源码
def fallback_schema_from_field(self, field):
        """ Fallback schema for field that isn't inspected properly by DRF
        and probably won't land in upstream canon due to its hacky nature only for doc purposes
        """
        title = force_text(field.label) if field.label else ''
        description = force_text(field.help_text) if field.help_text else ''

        # since we can't really inspect dictfield and jsonfield, at least display object as type
        # instead of string
        if isinstance(field, (serializers.DictField, serializers.JSONField)):
            return coreschema.Object(
                properties={},
                title=title,
                description=description
            )
项目:django-daiquiri    作者:aipescience    | 项目源码 | 文件源码
def to_internal_value(self, data):
        if not isinstance(data, dict):
            self.fail('invalid')

        return super(JSONField, self).to_internal_value(data)