feat: 100% async - native async serializers (adata/asave/acreate), async cache (redis.asyncio), view call-site migration
This commit is contained in:
@@ -35,7 +35,7 @@ class CompressionHistoryListView(APIView):
|
||||
|
||||
return JsonResponse({
|
||||
'success': True,
|
||||
'data': serializer.data,
|
||||
'data': await serializer.adata,
|
||||
'total': total,
|
||||
'page': page,
|
||||
'page_size': page_size
|
||||
@@ -50,10 +50,10 @@ class CompressionHistoryListView(APIView):
|
||||
serializer = CompressionHistorySerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
# DRF 序列化器 save() 为同步 ORM 操作,sync_to_async 兜底
|
||||
await sync_to_async(serializer.save)()
|
||||
await serializer.asave()
|
||||
return JsonResponse({
|
||||
'success': True,
|
||||
'data': serializer.data
|
||||
'data': await serializer.adata
|
||||
}, status=status.HTTP_201_CREATED)
|
||||
|
||||
return JsonResponse({
|
||||
|
||||
Reference in New Issue
Block a user