def test_query_rel_fields(self):
        """
        Test add and edit form related fields filter
        """
        client = self.app.test_client()
        self.browser_login(client, USERNAME_ADMIN, PASSWORD_ADMIN)

        with model2_data(self.appbuilder.session, 2):
            # Base filter string starts with
            rv = client.get("/model2view/add")
            data = rv.data.decode("utf-8")
            self.assertIn("test0", data)
            self.assertNotIn("test1", data)

            model2 = (
                self.appbuilder.get_session.query(Model2)
                .filter_by(field_string="test0")
                .one_or_none()
            )
            # Base filter string starts with
            rv = client.get(f"/model2view/edit/{model2.id}")
            data = rv.data.decode("utf-8")
            self.assertIn("test1", data)

        Test add and edit form related fields filter
        
tests/test_mvc.py