Creates the `_fields`, `_forms` asn `_sets` dicts.

        Any properties which begin with an underscore or are not `Field`,
        `Form` or `FormSet` **instances** are ignored by this method.
483667
def _init_fields(self):
        
        fields = {}
        forms = {}
        sets = {}

        for name in dir(self):
            if name.startswith('_'):
                continue
            field = getattr(self, name)
            is_field = isinstance(field, Field)
            is_form = isinstance(field, Form) or (
                inspect.isclass(field) and issubclass(field, Form))
            is_set = isinstance(field, FormSet)

            if is_field:
                field = copy(field)
                field.name = self._prefix + name
                field.form = self
                if field.prepare is None:
                    field.prepare = getattr(self, 'prepare_' + name, None)
                if field.clean is None:
                    field.clean = getattr(self, 'clean_' + name, None)
                fields[name] = field
                setattr(self, name, field)
            elif is_form:
                forms[name] = field
            elif is_set:
                field._name = self._prefix + name  # REALLY IMPORTANT
                sets[name] = field

        self._fields = fields
        self._forms = forms
        self._sets = sets
1047497
def get_formset(self, form, name):
        
        kwargs = self.get_kwargs(form, name)
        formset_class = self.get_formset_class(form, name)
        formset = formset_class(
            form.data if form.is_bound else None,
            form.files if form.is_bound else None,
            **kwargs)
        return formset
1032775
def fields(cls):
        
        for property, descriptor in cls.__dict__.items():
            if isinstance(descriptor, MediaField):
                if isinstance(property, bytes):
                    # On Python 2, class field names are bytes. This method
                    # produces text strings.
                    yield property.decode('utf8', 'ignore')
                else:
                    yield property
105503
def autostrip(cls):
    
    warnings.warn(
        "django-annoying autostrip is deprecated and will be removed in a "
        "future version. Django now has native support for stripping form "
        "fields. "
        "https://docs.djangoproject.com/en/stable/ref/forms/fields/#django.forms.CharField.strip",
        DeprecationWarning,
        stacklevel=2,
    )
    fields = [(key, value) for key, value in cls.base_fields.items() if isinstance(value, forms.CharField)]
    for field_name, field_object in fields:
        def get_clean_func(original_clean):
            return lambda value: original_clean(value and value.strip())
        clean_func = get_clean_func(getattr(field_object, 'clean'))
        setattr(field_object, 'clean', clean_func)
    return cls
325965
def set_fields(self, **fields):
        
        for field_name, value in iteritems(fields):
            field = getattr(self, field_name)
            field.proxy_set(value)
655796
def attributes_properties(**options)
      options_set = Set.new options.keys.map(&:to_s)

      unless options_set.subset? Set.new(@fields)
        fail "You have to provide correct attribute names in" +
             "'attributes_properties' for '#{@model}'."
      end

      # TODO: Check for valid value for each key
      @field_details = options || {}
    end
314935
def _set_fields(self):
        
        self.fields = []
        self.required_input = []
        for member_name, member_object in inspect.getmembers(self.__class__):
            if inspect.isdatadescriptor(member_object) and not member_name.startswith("__"):
                self.fields.append(member_name)
                if member_object.required_input:
                    self.required_input.append(member_name)
1263928
def add_fields(self, form, index):
        
        super(ColumnFormSet, self).add_fields(form, index)
        form.fields['column'].choices = self.get_choices()
835285
def _serialize_model_helper(self, model, field_dict=None):
        
        field_dict = field_dict or self.dot_field_list_to_dict()
        if model is None:
            return None

        if isinstance(model, Query):
            model = model.all()

        if isinstance(model, (list, set)):
            return [self.serialize_model(m, field_dict=field_dict) for m in model]

        model_dict = {}
        for name, sub in six.iteritems(field_dict):
            value = getattr(model, name)
            if sub:
                value = self.serialize_model(value, field_dict=sub)
            model_dict[name] = value
        return model_dict
769362
def as_required_fields(self, fields=[]):
        
        fields = self.filter_fields(fields)
        for f in fields:
            f = self.fields[f.name]
            f.required = True
273090
def get_formset(self, request, obj=None, **kwargs):
        
        if self.declared_fieldsets:
            fields = flatten_fieldsets(self.declared_fieldsets)
        else:
            fields = None
        if self.exclude is None:
            exclude = []
        else:
            exclude = list(self.exclude)

        exclude.extend(kwargs.get("exclude", []))
        exclude.extend(self.get_readonly_fields(request, obj))

        # if exclude is an empty list we use None, since that's the actual
        # default
        exclude = exclude or None
        defaults = {
            "form": self.form,
            "formset": self.formset,
            "fk_name": self.fk_name,
            "fields": fields,
            "exclude": exclude,
            "formfield_callback": curry(self.formfield_for_dbfield, request=request),
            "extra": self.extra,
            "max_num": self.max_num,
            "can_delete": self.can_delete,
        }
        defaults.update(kwargs)

        return inlineformset_factory(self.parent_model, self.model, **defaults)
1118008
def get_form_schema(form):
    """"""
    schema = {
        'type': 'object',
        'properties': {},
    }

    for name, field in form.base_fields.items():
        schema['properties'][name] = get_field_schema(name, field)
        if field.required:
            schema.setdefault('required', []).append(name)

    return schema
118774
def formfield(self, **kwargs):
        """"""

        defaults = dict(
            form_class=LocalizedFieldForm,
            required=False if self.blank else self.required
        )
        defaults.update(kwargs)
        return super().formfield(**defaults)
1254891
def get_fields(model, fields, meta=None):
    
    model = get_model(model)
    if fields is not None:
        f = fields
    elif meta and hasattr(model, meta):
        m = getattr(model, meta)
        if hasattr(m, 'fields'):
            f = m.fields
        else:
            f = model._fields_list
    else:
        f = model._fields_list
        
    fields_list = []
    for x in f:
        field = {}
        if isinstance(x, str):  #so x is field_name
            field['name'] = x
        elif isinstance(x, tuple):
            field['name'] = x[0]
            field['field'] = x[1]
        elif isinstance(x, dict):
            field = x.copy()
        else:
            raise UliwebError('Field definition {!r} is not right, it should be just like (field_name, form_field_obj)'.format(x))
        
        if 'prop' not in field:
            if hasattr(model, field['name']):
                field['prop'] = getattr(model, field['name'])
            else:
                field['prop'] = None
        
        fields_list.append((field['name'], field))
    return fields_list
173865
def _construct_form(self, i, **kwargs):
        """"""
        form = super(MetadataFormset, self)._construct_form(i, **kwargs)
        # Monkey patch the form to always force a save.
        # It's unfortunate, but necessary because we always want an instance
        # Affect on performance shouldn't be too great, because ther is only
        # ever one metadata attached
        form.empty_permitted = False
        form.has_changed = lambda: True

        # Set a marker on this object to prevent automatic metadata creation
        # This is seen by the post_save handler, which then skips this
        # instance.
        if self.instance:
            self.instance.__seo_metadata_handled = True

        return form
1165936
def prepare_model(self, attrs):
        
        if isinstance(attrs, Model):
            attrs.client = self.client
            attrs.collection = self
            return attrs
        elif isinstance(attrs, dict):
            return self.model(attrs=attrs, client=self.client, collection=self)
        else:
            raise Exception("Can't create %s from %s" %
                            (self.model.__name__, attrs))
261639
def fieldset(title, items, options=None):
    """"""
    result = {
        'title': title,
        'type': 'fieldset',
        'items': items
    }
    if options is not None:
        result.update(options)

    return result