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.
This commit is contained in:
parent
0f888da376
commit
0634e5b536
1 changed files with 1 additions and 1 deletions
|
@ -89,7 +89,7 @@ class FileUploadView(GenericAPIView):
|
||||||
instance = serializer.save()
|
instance = serializer.save()
|
||||||
instance.category = Category.objects.get(id=kwargs["category"])
|
instance.category = Category.objects.get(id=kwargs["category"])
|
||||||
instance.save()
|
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:
|
else:
|
||||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
Loading…
Reference in a new issue