diff --git a/backend/apps/lycrontab/views/celery_task_result.py b/backend/apps/lycrontab/views/celery_task_result.py index 731a2b56b31f7193d70dc471efddcbcaad3e599d..48e340431b1e03ba24f2844be66afd993a2c7e99 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