From 0f3d94482763d7d50df7310b7e17b76f52160e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=83=98?= Date: Thu, 21 Dec 2023 15:45:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=A1=E5=88=92=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=89=A7=E8=A1=8C=E7=BB=93=E6=9E=9C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apps/lycrontab/views/celery_task_result.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/apps/lycrontab/views/celery_task_result.py b/backend/apps/lycrontab/views/celery_task_result.py index 731a2b5..48e3404 100644 --- a/backend/apps/lycrontab/views/celery_task_result.py +++ b/backend/apps/lycrontab/views/celery_task_result.py @@ -11,20 +11,25 @@ # ------------------------------ # django_celery_results TaskResult view # ------------------------------ +import json from django_celery_results.models import TaskResult +from rest_framework import serializers +from apps.lycrontab.filters import CeleryTaskResultFilterSet from utils.serializers import CustomModelSerializer from utils.viewset import CustomModelViewSet -from apps.lycrontab.filters import CeleryTaskResultFilterSet - - class CeleryTaskResultSerializer(CustomModelSerializer): """ 定时任务结果 序列化器 """ + result = serializers.SerializerMethodField(read_only=True) + + def get_result(self, obj): + return json.loads(obj.result) + class Meta: model = TaskResult fields = '__all__' @@ -36,4 +41,4 @@ class CeleryTaskResultViewSet(CustomModelViewSet): """ queryset = TaskResult.objects.all() serializer_class = CeleryTaskResultSerializer - filter_class = CeleryTaskResultFilterSet \ No newline at end of file + filter_class = CeleryTaskResultFilterSet -- Gitee