python类JSONField()的实例源码

test_field_converter.py 文件源码 项目:graphene-django 作者: graphql-python 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_should_json_convert_jsonstring():
    assert_conversion(serializers.JSONField, graphene.types.json.JSONString)
entities.py 文件源码 项目:drf_openapi 作者: limdauto 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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
            )
serializers.py 文件源码 项目:django-daiquiri 作者: aipescience 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def to_internal_value(self, data):
        if not isinstance(data, dict):
            self.fail('invalid')

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


问题


面经


文章

微信
公众号

扫码关注公众号