fix(achievement): 管理接口序列化 create_time 为字符串

_serialize 是手写 dict 而非 DRF 序列化器,原始 datetime 交给
JSON 编码器抛 TypeError,导致整个管理接口 500。

表为空时列表接口看着正常(不进循环),一旦有数据就全挂——
生产环境表现为:新建成就实际写库成功,但返回响应时炸掉,
前端弹窗不关、列表刷不出来,看起来像保存失败,于是重复点击建出多条。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 09:56:16 -06:00
parent 1504164ae8
commit cf5c3c5d2f

View File

@@ -119,5 +119,8 @@ def _serialize(a):
# 这个计数器是唯一的仪表盘 # 这个计数器是唯一的仪表盘
"unlock_count": a.unlock_count, "unlock_count": a.unlock_count,
"order": a.order, "order": a.order,
"create_time": a.create_time, # 必须 isoformat():这里是手写的 dict 而不是 DRF 序列化器,
# 原始 datetime 交给 JSON 编码器会抛 TypeError整个管理接口 500。
# 表为空时列表接口看着正常(不进循环),一旦有数据就全挂。
"create_time": a.create_time.isoformat() if a.create_time else None,
} }