I want to edit a django-rest-framwork
serializer object before it is saved. This is how I currently do it -
def upload(request):
if request.method == 'POST':
form = ImageForm(request.POST, request.FILES)
if form.is_valid(): # All validation rules pass
obj = form.save(commit=False)
obj.user_id = 15
obj.save()
How can I do it with a django-rest-framework
serializer object?
@api_view(['POST','GET'])
def upload_serializers(request):
if request.method == 'POST':
serializer = FilesSerializer(data=request.DATA, files=request.FILES)
if serializer.is_valid():
serializer.save()