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"
Initialize a field whether it is built with a custom name for a
dataset/ETHPy150Open stephenmcd/mezzanine/mezzanine/conf/forms.py/SettingsForm._init_field