def _convert_relation(self, prop, kwargs):
        # Check if relation is specified
        form_columns = getattr(self.view, 'form_columns', None)
        if form_columns and prop.key not in form_columns:
            return None

        remote_model = prop.mapper.class_
        column = prop.local_remote_pairs[0][0]

        # If this relation points to local column that's not foreign key, assume
        # that it is backref and use remote column data
        if not column.foreign_keys:
            column = prop.local_remote_pairs[0][1]

        kwargs['label'] = self._get_label(prop.key, kwargs)
        kwargs['description'] = self._get_description(prop.key, kwargs)

        # determine optional/required, or respect existing
        requirement_options = (validators.Optional, validators.InputRequired)
        if not any(isinstance(v, requirement_options) for v in kwargs['validators']):
            if column.nullable or prop.direction.name != 'MANYTOONE':
                kwargs['validators'].append(validators.Optional())
            else:
                kwargs['validators'].append(validators.InputRequired())

        # Contribute model-related parameters
        if kwargs not in 'allow_blank':
            kwargs['allow_blank'] = column.nullable

        # Override field type if necessary
        override = self._get_field_override(prop.key)
        if override:
            return override(**kwargs)

        if prop.direction.name == 'MANYTOONE' or not prop.uselist:
            return self._model_select_field(prop, False, remote_model, **kwargs)
        elif prop.direction.name == 'ONETOMANY':
            return self._model_select_field(prop, True, remote_model, **kwargs)
        elif prop.direction.name == 'MANYTOMANY':
            return self._model_select_field(prop, True, remote_model, **kwargs)
dataset/ETHPy150Open mrjoes/flask-admin/flask_admin/contrib/sqla/form.py/AdminModelConverter._convert_relation/swapped operands of `not in`