My code for receiving data and then returning the response is:
serializer = VideoSerializer(data=data, partial=True)
if serializer.is_valid():
serializer.save()
return JSONResponse(serializer.data, status=201)
return JSONResponse(serializer.errors, status=400)
Here if the serializer is valid I want to return partial data from the serializer(after removing some fields).
It could be done if I create another serializer object and pass fields tuple to it as given here https://stackoverflow.com/a/23674297/1694699 but that would mean another database call also I will have to query for the id to pass it to the new serializer object.
Is their any better approach?