Returns used fields of model
353528
def get_fields(self):
        
        result = [key for key in self.__original_data__.keys()
                  if key not in self.__deleted_fields__]
        result.extend([key for key in self.__modified_data__.keys()
                       if key not in result and key not in self.__deleted_fields__])

        return result
45411
def fields(self):
        
        result = self._get_key_values('fields')
        for key, value in result.items():
            if not isinstance(value, list):
                result[key] = [value]

        for key, value in result.items():
            schema = get_schema_from_type(key)
            for obj in value:
                if obj not in schema._declared_fields:
                    raise InvalidField("{} has no attribute {}".format(schema.__name__, obj))

        return result
1348538
def _get_model_fields(self, field_names, declared_fields, extra_kwargs):
        
        model = getattr(self.Meta, 'model')
        model_fields = {}

        for field_name in field_names:
            if field_name in declared_fields:
                # If the field is declared on the serializer
                field = declared_fields[field_name]
                source = field.source or field_name
            else:
                try:
                    source = extra_kwargs[field_name]['source']
                except KeyError:
                    source = field_name

            if '.' in source or source == '*':
                # Model fields will always have a simple source mapping,
                # they can't be nested attribute lookups.
                continue

            try:
                field = model._meta.get_field(source)
                if isinstance(field, DjangoModelField):
                    model_fields[source] = field
            except FieldDoesNotExist:
                pass

        return model_fields
1222438
def get_field_model(name, model=None):
    
    if '.' in name:
        m, name = name.split('.')
        model = get_model(m)

    if model:
        return getattr(model, name, None), model
    else:
        return None, None
1371773
def _get_default_field_names(self, declared_fields, model_info):
        
        return (
            [model_info.pk.name] +
            list(declared_fields.keys()) +
            list(model_info.fields.keys()) +
            list(model_info.relations.keys())
        )
743420
function(model) {
    var fields = _.keys(model);
    var updated = {};

    _.each(fields, function(field) {
        var updatedField = {};
        var modelField = {};
        if (!(field === Object(field))) {
            updatedField.field = field;
            if (!(model[field] === Object(model[field]))) {
                modelField = { type: model[field] };
            } else {
                modelField = model[field];
            }
            updatedField = _.defaults(updatedField, modelField);
        } else {
            updatedField = field;
        }
        updated[updatedField.field] = updatedField;
    });

    return updated;
}
851710
def get_rendered_fields(self, ctx=None):
        '''
        
        '''
        times = self._min_times
        if self._mutating() and self._in_repeat_stage():
            times += (self._current_index) * self._step
        return super(Repeat, self).get_rendered_fields(ctx) * times
883
def get_extra_fields(self, model, fields):
        """"""

        def revert_url(self):
            """URL for this change in the default admin site."""
            opts = model._meta
            app_label, model_name = opts.app_label, opts.model_name
            return reverse(
                "%s:%s_%s_simple_history" % (admin.site.name, app_label, model_name),
                args=[getattr(self, opts.pk.attname), self.history_id],
            )

        def get_instance(self):
            attrs = {
                field.attname: getattr(self, field.attname) for field in fields.values()
            }
            if self._history_excluded_fields:
                excluded_attnames = [
                    model._meta.get_field(field).attname
                    for field in self._history_excluded_fields
                ]
                values = (
                    model.objects.filter(pk=getattr(self, model._meta.pk.attname))
                    .values(*excluded_attnames)
                    .get()
                )
                attrs.update(values)
            return model(**attrs)

        def get_next_record(self):
            """
            Get the next history record for the instance. `None` if last.
            """
            history = utils.get_history_manager_for_model(self.instance)
            return (
                history.filter(Q(history_date__gt=self.history_date))
                .order_by("history_date")
                .first()
            )

        def get_prev_record(self):
            """
            Get the previous history record for the instance. `None` if first.
            """
            history = utils.get_history_manager_for_model(self.instance)
            return (
                history.filter(Q(history_date__lt=self.history_date))
                .order_by("history_date")
                .last()
            )

        extra_fields = {
            "history_id": self._get_history_id_field(),
            "history_date": models.DateTimeField(),
            "history_change_reason": self._get_history_change_reason_field(),
            "history_type": models.CharField(
                max_length=1,
                choices=(("+", _("Created")), ("~", _("Changed")), ("-", _("Deleted"))),
            ),
            "history_object": HistoricalObjectDescriptor(
                model, self.fields_included(model)
            ),
            "instance": property(get_instance),
            "instance_type": model,
            "next_record": property(get_next_record),
            "prev_record": property(get_prev_record),
            "revert_url": revert_url,
            "__str__": lambda self: "{} as of {}".format(
                self.history_object, self.history_date
            ),
        }

        extra_fields.update(self._get_history_related_field(model))
        extra_fields.update(self._get_history_user_fields())

        return extra_fields
148323
public function getUsedFields()
    {
        if (empty($this->usedFields)) {
            $this->usedFields = [];
            foreach (AddressField::getAll() as $field) {
                if (strpos($this->format, '%' . $field) !== false) {
                    $this->usedFields[] = $field;
                }
            }
        }

        return $this->usedFields;
    }
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 []
464705
def get_rendered_fields(self, ctx=None):
        '''
        
        '''
        if ctx is None:
            ctx = RenderContext()
        ctx.push(self)
        result = []
        for f in self._fields:
            if len(f.render(ctx)):
                result.append(f)
        ctx.pop()
        return result
1187148
def get_reference_fields(self, exclude_models=None):
        
        if exclude_models is None:
            exclude_models = []
        result = []
        for django_model in django.apps.apps.get_models():
            if any([issubclass(django_model, m) for m in exclude_models]):
                continue
            for django_field in django_model._meta.fields:
                if isinstance(django_field, models.ForeignKey) and django_field.related.to == Item:
                    result = [(m, f) for (m, f) in result if not issubclass(django_model, m)]
                    result.append((django_model, django_field))
        return result
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
674162
def get_model_fields(model, add_reserver_flag=True):
    
    import uliweb.orm as orm

    fields = []
    m = {'type':'type_name', 'hint':'hint',
         'default':'default', 'required':'required'}
    m1 = {'index':'index', 'unique':'unique'}
    for name, prop in model.properties.items():
        if name == 'id':
            continue
        d = {}
        for k, v in m.items():
            d[k] = getattr(prop, v)
        for k, v in m1.items():
            d[k] = bool(prop.kwargs.get(v))
        d['name'] = prop.fieldname or name
        d['verbose_name'] = unicode(prop.verbose_name)
        d['nullable'] = bool(prop.kwargs.get('nullable', orm.__nullable__))
        if d['type'] in ('VARCHAR', 'CHAR', 'BINARY', 'VARBINARY'):
            d['max_length'] = prop.max_length
        if d['type'] in ('Reference', 'OneToOne', 'ManyToMany'):
            d['reference_class'] = prop.reference_class
            #collection_name will be _collection_name, it the original value
            d['collection_name'] = prop._collection_name
        d['server_default'] = prop.kwargs.get('server_default')
        d['_reserved'] = True
        fields.append(d)

    return fields
215856
def _get_simple_fields(self):
        
        fields = []
        for field_name in self.cls._fields:
            field = self.cls.get_field(field_name)
            if not isinstance(field, MultiValuesField):
                fields.append(field_name)
        return fields
1363957
def get_field_from_model_by_name(model_class, field_name):
    
    return first_match(lambda x: x if x.name == field_name else None, model_class._meta.fields)
1365242
def get_version_fields(self):
        
        options = reversion._get_options(self)
        return options.fields or [f.name for f in self._meta.fields if f not in options.exclude]