Returns positional arguments for related model query.
359639
def get_cleaned_args(self, args):
        
        if not args:
            return args

        cleaned_args = []
        for arg in args:
            condition = self._get_linguist_condition(arg, True)
            if condition:
                cleaned_args.append(condition)

        return cleaned_args
1322012
def add_eager_constraints(self, models):
        
        key = "%s.%s" % (self._related.get_table(), self._other_key)

        self._query.where_in(key, self._get_eager_model_keys(models))
591913
def get_url_kwargs(self, request_kwargs=None, **kwargs):
        

        if not request_kwargs:
            request_kwargs = getattr(self, 'kwargs', {})

        kwargs = super(ModelCMSView, self).get_url_kwargs(request_kwargs,
                                                          **kwargs)
        obj = kwargs.pop('object', None)
        if obj:
            kwargs[self.slug_url_kwarg] = getattr(obj, self.slug_field, None)
        elif self.slug_url_kwarg in request_kwargs:
            kwargs[self.slug_url_kwarg] = request_kwargs[self.slug_url_kwarg]

        return kwargs
86333
def _get_build_kwargs(self, obj, pk_set=None, action=None, update_fields=None, reverse=None, **kwargs):
        """"""
        if action is None:
            # Check filter before rebuilding index.
            if not self._filter([obj], update_fields=update_fields):
                return

            queryset = getattr(obj, self.accessor).all()

            # Special handling for relations to self.
            if self.field.rel.model == self.field.rel.related_model:
                queryset = queryset.union(getattr(obj, self.field.rel.get_accessor_name()).all())

            return {'queryset': queryset}
        else:
            # Update to relation itself, only update the object in question.
            if self.field.rel.model == self.field.rel.related_model:
                # Special case, self-reference, update both ends of the relation.
                pks = set()
                if self._filter(self.model.objects.filter(pk__in=pk_set)):
                    pks.add(obj.pk)

                if self._filter(self.model.objects.filter(pk__in=[obj.pk])):
                    pks.update(pk_set)

                return {'queryset': self.index.object_type.objects.filter(pk__in=pks)}
            elif isinstance(obj, self.model):
                # Need to switch the role of object and pk_set.
                result = {'queryset': self.index.object_type.objects.filter(pk__in=pk_set)}
                pk_set = {obj.pk}
            else:
                result = {'obj': obj}

            if action != 'post_clear':
                # Check filter before rebuilding index.
                if not self._filter(self.model.objects.filter(pk__in=pk_set)):
                    return

            return result
494126
def params(self):
        
        params = odict([])
        for key,model in self.models.items():
            params.update(model.params)
        return params
811167
def related_to(self):
        
        params = []
        constraints = self.in_constraints
        if self.is_constraint is not None:
            constraints.append(self.is_constraint)

        for constraint in constraints:
            for var in constraint._vars:
                param = var.get_parameter()
                if param not in params and param.uniqueid != self.uniqueid:
                    params.append(param)

        return params
1188652
def _get_eager_model_keys(self, models):
        
        keys = []

        for model in models:
            value = getattr(model, self._foreign_key)

            if value is not None and value not in keys:
                keys.append(value)

        if not len(keys):
            return [0]

        return keys
700781
def get_queryset(self, *args, **kwargs):
        
        qs = super(AutoPrefetchMixin, self).get_queryset(*args, **kwargs)
        included_resources = get_included_resources(self.request)

        for included in included_resources:
            included_model = None
            levels = included.split('.')
            level_model = qs.model
            for level in levels:
                if not hasattr(level_model, level):
                    break
                field = getattr(level_model, level)
                field_class = field.__class__

                is_forward_relation = (
                    issubclass(field_class, ForwardManyToOneDescriptor) or
                    issubclass(field_class, ManyToManyDescriptor)
                )
                is_reverse_relation = (
                    issubclass(field_class, ReverseManyToOneDescriptor) or
                    issubclass(field_class, ReverseOneToOneDescriptor)
                )
                if not (is_forward_relation or is_reverse_relation):
                    break

                if level == levels[-1]:
                    included_model = field
                else:

                    if issubclass(field_class, ReverseOneToOneDescriptor):
                        model_field = field.related.field
                    else:
                        model_field = field.field

                    if is_forward_relation:
                        level_model = model_field.related_model
                    else:
                        level_model = model_field.model

            if included_model is not None:
                qs = qs.prefetch_related(included.replace('.', '__'))

        return qs
1197045
def getparams(self, param):
        

        return list(cparam for cparam in self.values() if cparam == param)
975891
def prepare_query_params(**kwargs):
    
    return [
        (sub_key, sub_value)
        for key, value in kwargs.items()
        for sub_key, sub_value in expand(value, key)
        if sub_value is not None
    ]
1007567
def kwargs(self):
    
    return {k: v for k, v in self._kwargs.items() if k not in self._INTERNAL_FIELDS}
721348
def _get_concrete_fields_with_model(self):
        
        return [
            (f, f.model if f.model != self.model else None)
            for f in self.model._meta.get_fields()
            if f.concrete
            and (
                not f.is_relation or f.one_to_one or (f.many_to_one and f.related_model)
            )
        ]
602122
def get_mongo_query_from_arguments(self, reserved_attributes=[]):
        

        query = {}
        for arg in self.request.arguments:
            if arg not in reserved_attributes:
                if len(self.request.arguments.get(arg)) > 1:
                    query["$or"] = []
                    for val in self.request.arguments.get(arg):
                        query["$or"].append({arg: self.get_arg_value_as_type(val)})
                else:
                    query[arg] = self.get_arg_value_as_type(self.request.arguments.get(arg)[0])

        return query
41991
def _getParameters(self):
        """"""
        param = self.query._getParameters()                   
        param[self.__key] =  self.__value
        return param
458139
def get_record_params(args):
    
    name, rtype, content, ttl, priority = (
        args.name, args.rtype, args.content, args.ttl, args.priority)
    return name, rtype, content, ttl, priority
176504
def get_nested_relation_kwargs(field_name, relation_info):
    
    kwargs = get_relation_kwargs(field_name, relation_info)
    kwargs.pop('queryset')
    kwargs.pop('required')
    kwargs['read_only'] = True
    return kwargs
1296806
def query_all(self):
        
        return self.query_model(self.model, self.condition, order_by=self.order_by,
                                group_by=self.group_by, having=self.having)