def process_data(self, value):
        """
        Process the Python data applied to this field and store the result.
        This will be called during form construction by the form's `kwargs` or
        `obj` argument.

        Converting ORM object to primary key for client form.

        :param value: The python object containing the value to process.
        """
        if value:
            if self.is_related:
                self.data = self.datamodel.get_related_interface(
                    self.col_name
                ).get_pk_value(value)
            else:
                self.data = self.datamodel.get(value)
        else:
            self.data = None

        Process the Python data applied to this field and store the result.
        This will be called during form construction by the form's `kwargs` or
        `obj` argument.

        Converting ORM object to primary key for client form.

        :param value: The python object containing the value to process.
        
flask_appbuilder/fields.py