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

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

项目:apimas    作者:grnet    | 项目源码 | 文件源码
def _get_ref_params(self, instance, loc, top_spec, automated,
                        field_kwargs):
        """
        Get extra params needed to initialize a
        `serializers.HyperlinkedIdentityField`.
        """
        ref_kwargs = instance['.ref']
        many = ref_kwargs.get('many', False)
        ref = ref_kwargs['to']
        endpoint, collection = tuple(ref.split('/'))
        extra = {'view_name': '%s-detail' % (endpoint + '_' + collection)}
        if not automated:
            extra['many'] = many
            if not field_kwargs.get('read_only'):
                # In case it is not a read only field, specify its queryset.
                ref_model = self._get_or_import_model(
                    endpoint + '/' + collection,
                    loc[:1] + ('.drf_collection', 'model'), top_spec)
                extra['queryset'] = ref_model.objects.all()
        return extra
项目:ChRIS_ultron_backEnd    作者:FNNDSC    | 项目源码 | 文件源码
def _get_related_fields(self, fields, id_field):
        return [k for (k, v) in fields
                if k != id_field
                and (isinstance(v, HyperlinkedRelatedField)
                or isinstance(v, HyperlinkedIdentityField)   
                or isinstance(v, ItemLinkField)
                or (isinstance(v, ManyRelatedField)
                    and isinstance(v.child_relation, HyperlinkedRelatedField)))]