From f6e41dc3495ae7f08315a2808db4c82c251c88ca Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Thu, 4 Jun 2026 04:48:25 -0600 Subject: [PATCH] fix --- account/decorators.py | 1 + utils/api/api.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/account/decorators.py b/account/decorators.py index 275db5e..c5dec8f 100644 --- a/account/decorators.py +++ b/account/decorators.py @@ -14,6 +14,7 @@ from .models import ProblemPermission class BasePermissionDecorator(object): def __init__(self, func): self.func = func + functools.update_wrapper(self, func) def __get__(self, obj, obj_type): if inspect.iscoroutinefunction(self.func): diff --git a/utils/api/api.py b/utils/api/api.py index 2d610be..a8a99f1 100644 --- a/utils/api/api.py +++ b/utils/api/api.py @@ -252,10 +252,13 @@ def validate_serializer(serializer): self = args[0] request = args[1] s = serializer(data=request.data) - if s.is_valid(): + if await sync_to_async(s.is_valid)(): request.data = s.data request.serializer = s - return await view_method(*args, **kwargs) + response = view_method(*args, **kwargs) + if asyncio.iscoroutine(response): + return await response + return response else: return self.invalid_serializer(s) return async_handle