From 0634e5b53674aee85712a628aec5ada5f46a175a Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 16 Mar 2024 21:52:20 +0100 Subject: [PATCH] feat(users): enhance media serializer context Updated the FileUploadView by adding request context to the OriginalMediaSerializer. This enhancement ensures that the serialization process has access to the request data, which can be crucial for accurately constructing URLs and handling permissions. By including the request context, we can now generate more dynamic and context-aware serialized data, improving the API's flexibility and the client's ability to utilize the provided data effectively. This change is a direct response to the need for more detailed and context-sensitive responses from our API endpoints, facilitating better integration with frontend components that rely on complete and accurate URL constructions for media assets. --- quackscape/users/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quackscape/users/views.py b/quackscape/users/views.py index 771a3d4..5c15108 100644 --- a/quackscape/users/views.py +++ b/quackscape/users/views.py @@ -89,7 +89,7 @@ class FileUploadView(GenericAPIView): instance = serializer.save() instance.category = Category.objects.get(id=kwargs["category"]) instance.save() - return Response(OriginalMediaSerializer(instance).data, status=status.HTTP_201_CREATED) + return Response(OriginalMediaSerializer(instance, context={'request': request}).data, status=status.HTTP_201_CREATED) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)