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 = {}