Register config name from field widgets

        Arguments:
            *args: Fields that contains widget
                :class:`djangocodemirror.widget.CodeMirrorWidget`.

        Returns:
            list: List of registered config names from fields.
12270
def register_from_fields(self, *args):
        
        names = []
        for field in args:
            widget = self.resolve_widget(field)
            self.register(widget.config_name)
            if widget.config_name not in names:
                names.append(widget.config_name)

        return names
550336
def get_field_names(self):
        
        field_names = super(StationDataIO, self).get_field_names()
        if set(field_names) == set(['meta', 'data']):
            meta_fields = list(self.data[0]['meta'].keys())
            if set(meta_fields) < set(self.getvalue('meta')):
                meta_fields = self.getvalue('meta')
            field_names = list(meta_fields) + ['data']
        return field_names
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
1156410
def formfield(self, **kwargs):
        

        defaults = {
            'form_class': forms.CharField,
            'required': False
        }

        defaults.update(kwargs)

        form_field = super().formfield(**defaults)
        form_field.widget = forms.HiddenInput()

        return form_field
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())
        )
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
559580
def as_widget(self, widget=None, attrs=None, only_initial=False):
        
        if not widget:
            widget = self.field.widget

        if DJANGO_VERSION > (1, 10):
            # so that we can refer to the field when building the rendering context
            widget._field = self.field
            # Make sure that NgWidgetMixin is not already part of the widget's bases so it doesn't get added twice.
            if not isinstance(widget, NgWidgetMixin):
                widget.__class__ = type(widget.__class__.__name__, (NgWidgetMixin, widget.__class__), {})
        return super(NgBoundField, self).as_widget(widget, attrs, only_initial)
1067027
def key_values_cache_key_name(cls, *key_fields):
        
        key_fields = key_fields or cls.KEY_FIELDS
        return 'configuration/{}/key_values/{}'.format(cls.__name__, ','.join(key_fields))
325965
def set_fields(self, **fields):
        
        for field_name, value in iteritems(fields):
            field = getattr(self, field_name)
            field.proxy_set(value)
199584
def get_field_name_for(cls, field_name, dynamic_part):
        
        field = cls.get_field(field_name)
        return field.get_name_for(dynamic_part)
387908
def get_all_fields(self):
        """"""
        return {
            name: {
                'name': name,
                'label': field['label'],
            }
            for name, field in self.get_model_config().get_list_fields().items()
        }
1288052
def get_api_field_data(self):
        
        field = self.setup_field()
        d = {
            'class': field.__class__.__name__,
            'widget': {
                'class': field.widget.__class__.__name__
            }
        }

        try:
            d['input_type'] = field.widget.input_type
        except AttributeError:
            # some widgets, such as Select do not have an input type
            # in django < 1.11
            d['input_type'] = None

        return d
536830
def parse(self):
        """"""
        for line in self.lines:
            # Parse the line
            field_defs = self.parse_line(line)
            fields = []

            # Convert field parameters into Field objects
            for (kind, options) in field_defs:
                logger.debug("Creating field %s(%r)", kind, options)
                fields.append(self.field_registry.create(kind, **options))

            # Add the list of Field objects to the 'fields per line'.
            self.line_fields.append(fields)

            # Pre-fill the list of widgets
            for field in fields:
                self.widgets[field] = None
1255171
def _init_field(self, setting, field_class, name, code=None):
        
        kwargs = {
            "label": setting["label"] + ":",
            "required": setting["type"] in (int, float),
            "initial": getattr(settings, name),
            "help_text": self.format_help(setting["description"]),
        }
        if setting["choices"]:
            field_class = forms.ChoiceField
            kwargs["choices"] = setting["choices"]
        field_instance = field_class(**kwargs)
        code_name = ('_modeltranslation_' + code if code else '')
        self.fields[name + code_name] = field_instance
        css_class = field_class.__name__.lower()
        field_instance.widget.attrs["class"] = css_class
        if code:
            field_instance.widget.attrs["class"] += " modeltranslation"
916049
def extract_fieldnames(config):
    
    fields = []
    for x in get_fields(config):
        if x in fields:
            fields.append(x + '_' + str(fields.count(x) + 1))
        else:
            fields.append(x)
    return fields
76742
public List<String> getRegisteredWidgetNames() {

        List<String> result = new ArrayList<String>(m_registeredWidgets.keySet());
        return result;
    }
544770
def register(self, ModelClass, form_field=None, widget=None, title=None, prefix=None, has_id_value=True):
        
        if any(urltype.model == ModelClass for urltype in self._url_types):
            raise ValueError("Model is already registered: '{0}'".format(ModelClass))

        opts = ModelClass._meta
        opts = opts.concrete_model._meta

        if not prefix:
            # Store something descriptive, easier to lookup from raw database content.
            prefix = '{0}.{1}'.format(opts.app_label, opts.object_name.lower())
        if not title:
            title = ModelClass._meta.verbose_name

        if self.is_external_url_prefix(prefix):
            raise ValueError("Invalid prefix value: '{0}'.".format(prefix))
        if self[prefix] is not None:
            raise ValueError("Prefix is already registered: '{0}'".format(prefix))
        if form_field is not None and widget is not None:
            raise ValueError("Provide either a form_field or widget; use the widget parameter of the form field instead.")

        urltype = UrlType(ModelClass, form_field, widget, title, prefix, has_id_value)
        signals.post_save.connect(_on_model_save, sender=ModelClass)
        self._url_types.append(urltype)
        return urltype