From e1c7ae168751a78b45769f61e02bdbef4c17f334 Mon Sep 17 00:00:00 2001 From: Nikolay Zarochintsev <73779940+diskream@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:54:37 +0300 Subject: [PATCH] fix: unhandled exception during AjaxSelect load (#727) --- sqladmin/widgets.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sqladmin/widgets.py b/sqladmin/widgets.py index 28f38b43..f1be146d 100644 --- a/sqladmin/widgets.py +++ b/sqladmin/widgets.py @@ -54,7 +54,10 @@ def __call__(self, field: Field, **kwargs: Any) -> Markup: kwargs["data-json"] = json.dumps(result) kwargs["multiple"] = "1" else: - data = field.loader.format(field.data) + try: + data = field.loader.format(field.data) + except Exception: + data = None if data: kwargs["data-json"] = json.dumps([data])