Return tha parent_lookup_field for the NestedHyperlinkedModelSerializer.
        If `parent_lookup_field` of `parent_model` is not defined lookup ForeignKey field of model.
        :return: parent_lookup_field
552256
def get_parent_lookup_field(self):
        
        if hasattr(self.Meta, "parent_lookup_field"):
            return getattr(self.Meta, "parent_lookup_field")
        elif hasattr(self.Meta, "parent_model"):
            model = getattr(self.Meta, "parent_model")
        else:
            parent_models = filter(
                lambda field: isinstance(field, db_models.ForeignKey),
                self.Meta.model._meta.fields
            )
            assert len(parent_models) > 0, self.default_error_messages['no_parent']
            assert len(parent_models) == 1, self.default_error_messages['multiple_parents']
            model = parent_models[0].related_model

        return '%(model_name)s__pk' % {
            'app_label': model._meta.app_label,
            'model_name': model._meta.object_name.lower()
        }
1366207
def query_parent_objects(self, context, query=None):
        

        # return the object values if we have no catalog query
        if query is None:
            return self.get_parent_objects(context)

        # avoid undefined reference of catalog in except...
        catalog = None

        # try to fetch the results via the catalog
        try:
            catalogs = api.get_catalogs_for(context)
            catalog = catalogs[0]
            return map(api.get_object, catalog(query))
        except (IndexError, UnicodeDecodeError, ParseError, APIError) as e:
            # fall back to the object values of the parent
            logger.warn("UniqueFieldValidator: Catalog query {} failed "
                        "for catalog {} ({}) -> returning object values of {}"
                        .format(query, repr(catalog), str(e),
                                repr(api.get_parent(context))))
            return self.get_parent_objects(context)
1196329
def is_inheritance_parent(self, field):
        '''
        
        '''
        return (
            isinstance(field, related.OneToOneField) and
            field.primary_key and
            issubclass(field.model, get_remote_field_to(field))
        )
733797
def get_fields(self):
        
        ret = OrderedDict()

        # no rights to see anything
        if not self.user:
            return ret

        # all fields that can be accessed through serializer
        fields = super(ModelPermissionsSerializer, self).get_fields()

        # superuser can see all the fields
        if self.user.is_superuser:
            return fields

        # fields that can be accessed by auhtenticated user
        allowed_fields = self._get_user_allowed_fields()
        for allowed_field in allowed_fields:
            field = fields[allowed_field.name]

            # subfields are NestedModelSerializer
            if isinstance(field, ModelPermissionsSerializer):
                # no rights on subfield's fields
                # calculate how the relation should be retrieved
                if not field.get_fields():
                    field_cls = field._related_class
                    kwargs = get_relation_kwargs(allowed_field.name,
                                                 field.info)
                    if not issubclass(field_cls,
                                      serializers.HyperlinkedRelatedField):
                        kwargs.pop('view_name', None)
                    field = field_cls(**kwargs)

            ret[allowed_field.name] = field
        return ret
1302531
function getParent(model, path) {
    var getParentMethod = inner(model).getParent;
    return getParentMethod ? getParentMethod.call(model, path) : model.parentModel;
}
232443
def parent(self):
        
        path = self.raw_path
        if not path or path == "/":
            if self.raw_fragment or self.raw_query_string:
                return URL(self._val._replace(query="", fragment=""), encoded=True)
            return self
        parts = path.split("/")
        val = self._val._replace(path="/".join(parts[:-1]), query="", fragment="")
        return URL(val, encoded=True)
943610
def get_fk_widget(cls, field):
        
        return functools.partial(
            widgets.ForeignKeyWidget,
            model=get_related_model(field))
607078
def get_child(parent, child_index):
    
    if child_index < 0 or child_index >= len(parent.childNodes):
        return None
    return parent.childNodes[child_index]
88054
def get_parent_objects(self, context):
        
        parent_object = api.get_parent(context)
        portal_type = api.get_portal_type(context)
        return parent_object.objectValues(portal_type)
38775
def parent(self):
        
        if self._has_parent is None:
            _parent = self._ctx.backend.get_parent(self._ctx.dev)
            self._has_parent = _parent is not None
            if self._has_parent:
                self._parent = Device(_parent, self._ctx.backend)
            else:
                self._parent = None
        return self._parent
71499
def get_parent(self):
        
        if not self.parent:
            parent = self._safe_get_element('ParentASIN')
            if parent:
                self.parent = self.api.lookup(ItemId=parent)
        return self.parent
1136022
def get_field_type(field):
    
    if isinstance(field, core_filters.MappedMultipleChoiceFilter):
        return ' | '.join(['"%s"' % f for f in sorted(field.mapped_to_model)])
    if isinstance(field, OrderingFilter) or isinstance(field, ChoiceFilter):
        return ' | '.join(['"%s"' % f[0] for f in field.extra['choices']])
    if isinstance(field, ChoiceField):
        return ' | '.join(['"%s"' % f for f in sorted(field.choices)])
    if isinstance(field, HyperlinkedRelatedField):
        if field.view_name.endswith('detail'):
            return 'link to %s' % reverse(field.view_name,
                                          kwargs={'%s' % field.lookup_field: "'%s'" % field.lookup_field})
        return reverse(field.view_name)
    if isinstance(field, structure_filters.ServiceTypeFilter):
        return ' | '.join(['"%s"' % f for f in SupportedServices.get_filter_mapping().keys()])
    if isinstance(field, ResourceTypeFilter):
        return ' | '.join(['"%s"' % f for f in SupportedServices.get_resource_models().keys()])
    if isinstance(field, core_serializers.GenericRelatedField):
        links = []
        for model in field.related_models:
            detail_view_name = core_utils.get_detail_view_name(model)
            for f in field.lookup_fields:
                try:
                    link = reverse(detail_view_name, kwargs={'%s' % f: "'%s'" % f})
                except NoReverseMatch:
                    pass
                else:
                    links.append(link)
                    break
        path = ', '.join(links)
        if path:
            return 'link to any: %s' % path
    if isinstance(field, core_filters.ContentTypeFilter):
        return "string in form 'app_label'.'model_name'"
    if isinstance(field, ModelMultipleChoiceFilter):
        return get_field_type(field.field)
    if isinstance(field, ListSerializer):
        return 'list of [%s]' % get_field_type(field.child)
    if isinstance(field, ManyRelatedField):
        return 'list of [%s]' % get_field_type(field.child_relation)
    if isinstance(field, ModelField):
        return get_field_type(field.model_field)

    name = field.__class__.__name__
    for w in ('Filter', 'Field', 'Serializer'):
        name = name.replace(w, '')
    return FIELDS.get(name, name)
628744
def get_serializer_info(self, serializer):
        
        if hasattr(serializer, 'child'):
            # If this is a `ListSerializer` then we want to examine the
            # underlying child serializer instance instead.
            serializer = serializer.child
        return self.get_fields(serializer.fields)
834217
def _get_request_fields_from_parent(self):
        """"""
        if not self.parent:
            return None

        if not getattr(self.parent, 'request_fields'):
            return None

        if not isinstance(self.parent.request_fields, dict):
            return None

        return self.parent.request_fields.get(self.field_name)
346489
def get_parent(self):
        
        if not self._parent:
            self._parent = yield self.parent_resource.get(self.parent_id)

        raise Return(self._parent)
235280
def get_parent_bank_nodes(self):
        
        parent_bank_nodes = []
        for node in self._my_map['parentNodes']:
            parent_bank_nodes.append(BankNode(
                node._my_map,
                runtime=self._runtime,
                proxy=self._proxy,
                lookup_session=self._lookup_session))
        return BankNodeList(parent_bank_nodes)
796072
def build_url_field(self, field_name, model_class):
        
        field_class = self.serializer_url_field
        field_kwargs = rest_framework.serializers.get_url_kwargs(model_class)
        field_kwargs.update({"parent_lookup_field": self.get_parent_lookup_field()})
        return field_class, field_kwargs