From d27a458f6b492ec7d9192cab0396045d97d6a7fc Mon Sep 17 00:00:00 2001 From: root Date: Sat, 12 Jul 2025 23:43:22 +0800 Subject: [PATCH] fix: template --- python_core/database/template_postgres.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python_core/database/template_postgres.py b/python_core/database/template_postgres.py index 8e245c8..ff8f1d9 100644 --- a/python_core/database/template_postgres.py +++ b/python_core/database/template_postgres.py @@ -699,6 +699,13 @@ PostgreSQL 驱动 psycopg2 未安装。请安装: draft_content = row.get('draft_content', {}) if isinstance(draft_content, dict): template_info.draft_content = draft_content + elif isinstance(draft_content, str): + # 如果是字符串,尝试解析为 JSON + try: + template_info.draft_content = json.loads(draft_content) + except (json.JSONDecodeError, TypeError): + logger.warning(f"Failed to parse draft_content JSON for template {row['id']}: {draft_content}") + template_info.draft_content = {} else: template_info.draft_content = {}