From b016e5ed5536059da4bc2911bae1862c90f22dfd Mon Sep 17 00:00:00 2001 From: 27942 <1313123@342> Date: Sun, 1 Feb 2026 13:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=B6=E5=BA=A6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/views.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/business/views.py b/business/views.py index a902c70..1ec060c 100644 --- a/business/views.py +++ b/business/views.py @@ -2931,12 +2931,19 @@ class BulletinDetail(APIView): user_agents_page = paginator.page(paginator.num_pages) data = [] for info in user_agents_page.object_list: + # 解析 file 字段:有文件返回数组,无文件返回空字符串 + try: + file_list = json.loads(info.file) if info.file else [] + except (json.JSONDecodeError, TypeError): + file_list = [] + # 空列表返回空字符串 + file_result = file_list if file_list else "" data.append({ "id": info.id, "title": info.title, "content": info.content, "times": info.times, - "file": info.file, + "file": file_result, "username": info.username, "state": info.state, }) @@ -5054,12 +5061,19 @@ class SystemList(APIView): user_agents_page = paginator.page(paginator.num_pages) data = [] for info in user_agents_page.object_list: + # 解析 file 字段:有文件返回数组,无文件返回空字符串 + try: + file_list = json.loads(info.file) if info.file else [] + except (json.JSONDecodeError, TypeError): + file_list = [] + # 空列表返回空字符串 + file_result = file_list if file_list else "" data.append({ "id": info.id, "title": info.title, "content": info.content, "times": info.times, - "file": info.file, + "file": file_result, "username": info.username, "state": info.state, })