Extract the search fields from the model.
344717
def get_search_field_values(contentitem):
    
    plugin = contentitem.plugin
    values = []
    for field_name in plugin.search_fields:
        value = getattr(contentitem, field_name)

        # Just assume all strings may contain HTML.
        # Not checking for just the PluginHtmlField here.
        if value and isinstance(value, six.string_types):
            value = get_cleaned_string(value)

        values.append(value)

    return values
162496
def plantloopfields(data, commdct):
    """"""
    fieldlists = plantloopfieldlists(data)
    objkey = 'plantloop'.upper()
    return extractfields(data, commdct, objkey, fieldlists)
1024387
def _from_fields(self, fields):
        '''
        

        '''
        return _np.dtype(self.dtype()).type(next(fields))
849811
def search(self):
        
        results = self.index.objects.all()
        # reduce the results based on the q field
        if self.cleaned_data.get("q"):
            results = results.query(
                "multi_match",
                query=self.cleaned_data['q'],
                fields=self.get_fields(),
                # this prevents ES from erroring out when a string is used on a
                # number field (for example)
                lenient=True
            )

        return results
757032
def get_field_info(model):
    
    opts = model._meta.concrete_model._meta

    pk = _get_pk(opts)
    fields = _get_fields(opts)
    forward_relations = _get_forward_relationships(opts)
    reverse_relations = _get_reverse_relationships(opts)
    fields_and_pk = _merge_fields_and_pk(pk, fields)
    relationships = _merge_relationships(forward_relations, reverse_relations)

    return FieldInfo(pk, fields, forward_relations, reverse_relations,
                     fields_and_pk, relationships)
574995
def to_dict(self, search_fields=None):
        """"""
        fields = self._fields
        if search_fields == 'update':
            fields = self._search_for_update_fields
        elif search_fields == 'all':
            fields = self._all_searchable_fields
        elif search_fields == 'exclude':
            # exclude search fields for update actions,
            # but include updateable_search_fields
            fields = [field for field in self._fields
                      if field in self._updateable_search_fields or
                      field not in self._search_for_update_fields]

        return {field: self.field_to_dict(field) for field in fields
                if getattr(self, field, None) is not None}
506494
def _get_all_field_names(model):
    
    return list(set(chain.from_iterable(
        (field.name, field.attname) if hasattr(field, 'attname') else (field.name,)
        for field in model._meta.get_fields()
        # For complete backwards compatibility, you may want to exclude
        # GenericForeignKey from the results.
        if not (field.many_to_one and field.related_model is None)
    )))
21264
def _get_fields(self, fields, excludes, hotfixes):
        '''
        
        '''
        final_fields = {}
        fields = fields or []
        excludes = excludes or []

        for f in self.model._meta.fields:
            # If the field name is already present, skip
            if f.name in self.fields:
                continue

            # If field is not present in explicit field listing, skip
            if fields and f.name not in fields:
                continue

            # If field is in exclude list, skip
            if excludes and f.name in excludes:
                continue

            # If field is a relation, skip.
            if getattr(f, 'rel'):
                continue

            attr = {'model_attr': f.name}
            if f.has_default():
                attr['null_value'] = f.default

            if f.name in hotfixes:
                attr.update(hotfixes[f.name])

            final_fields[f.name] = django_field_to_index(f, **attr)

        return final_fields
911637
def get_index_fields(self):
        
        index_fields = self.get_meta_option('index', [])
        if index_fields:
            return index_fields

        model = getattr(self.model_serializer_meta, 'model', None)
        if model:
            pk_name = model._meta.pk.name
            if pk_name in self.child.get_fields():
                return [pk_name]

        return []
249933
def model_file_fields(self, model):
        
        for field in model._meta.fields:
            if isinstance(field, models.FileField):
                yield field
16728
def get_custom_fields(self):
        
        return CustomField.objects.filter(
            content_type=ContentType.objects.get_for_model(self))
850038
def get_search_form(self):
        
        magic_dico_form = self.get_dict_for_forms()
        forms = []
        initial = list(self.request.GET.lists())

        for key, value in magic_dico_form.items():
            form = Form()
            model = value["model"]
            if not value["fields"]:
                continue
            for field in value["fields"]:
                formfield = get_formfield(model, field)
                formfield.widget.attrs.update({'class': self.css_class})
                form.fields.update({
                    field : formfield
                })

            initial_tmp = {}
            for k, vals in initial:
                tmp_list = k.split(model.__name__ + "-")
                if len(tmp_list) == 2:
                    list_val_tmp = vals[0] if len(vals) == 1 else [val for val in vals if val != '']
                    initial_tmp[tmp_list[-1]] = list_val_tmp

            form.initial = initial_tmp
            form.prefix = model.__name__
            forms.append(form)
        return sorted(forms, key=lambda form: form.prefix)
864194
def get_fields(model, fields=None):
    
    include = [f.strip() for f in fields.split(',')] if fields else None
    return utils.get_fields(
        model,
        include
    )
1000778
def basic_search(self, pattern):
        
        lookup = None
        for pattern in pattern.split():
            query_part = models.Q()
            for field in SEARCH_FIELDS:
                query_part |= models.Q(**{'%s__icontains' % field: pattern})
            if lookup is None:
                lookup = query_part
            else:
                lookup |= query_part

        return self.get_queryset().filter(lookup)
331463
def get_fields(self):
        """"""
        fields = super(DataSerializer, self).get_fields()

        # Hide collections/entities fields on list views as fetching them may be expensive.
        if self.parent is not None:
            del fields['collections']
            del fields['entities']

        return fields
1193852
def get_fields(model):
    

    try:
        if hasattr(model, "knockout_fields"):
            fields = model.knockout_fields()
        else:
            try:
                fields = model_to_dict(model).keys()
            except Exception as e:
                fields = model._meta.get_fields()
        return fields

    # Crash proofing
    except Exception as e:
        logger.exception(e)
        return []
466977
def _get_model_fields(self, model, prefix=_field_prefix):
        
        fields = list()
        for field_name, field in model()._ordered_fields:
            # Filter the default fields
            if field_name not in getattr(model, '_DEFAULT_BASE_FIELDS', []):
                type_name = utils.to_camel(field.solr_type)
                required = self._marker_true if field.required is True else self._marker_false
                fields.append((prefix, field_name, type_name, required))

        return fields