def _convert_many_to_one(
        self,
        col_name,
        label,
        description,
        lst_validators,
        filter_rel_fields,
        form_props,
    ):
        """
        Creates a WTForm field for many to one related fields,
        will use a Select box based on a query. Will only
        work with SQLAlchemy interface.
        """
        query_func = self._get_related_query_func(col_name, filter_rel_fields)
        get_pk_func = self._get_related_pk_func(col_name)
        extra_classes = None
        allow_blank = True
        if not self.datamodel.is_nullable(col_name):
            lst_validators.append(validators.DataRequired())
            allow_blank = False
        else:
            lst_validators.append(validators.Optional())
        form_props[col_name] = QuerySelectField(
            label,
            description=description,
            query_func=query_func,
            get_pk_func=get_pk_func,
            allow_blank=allow_blank,
            validators=lst_validators,
            widget=Select2Widget(extra_classes=extra_classes),
        )
        return form_props

        Creates a WTForm field for many to one related fields,
        will use a Select box based on a query. Will only
        work with SQLAlchemy interface.
        
flask_appbuilder/forms.py