I Couldn't Upload Images Using Django Rest-framework
I couldn't upload images using Django Rest-framework through POSTMAN , But I can do the same using Django Admin. When I try to debug the code, It's found that, serializer.is_valid(
Solution 1:
You can delete additional field in your serializer, models.ImageField
will use serializer.ImageField
by default.
classImageSerializer(serializers.ModelSerializer):
classMeta:
model=ImageUploadModel
fields=('usr_id','upImg','caption')
It should just work, your view code is correct
You could also use generics.CreateAPIView
to reduce a code.
classimageuploadView(generics.CreateAPIView):
queryset = ImageUploadModel.objects.all()
serializer_class = ImageSerializer
If it will not work, please update your answer with a serializer.errors
, you can check it in else
case
Post a Comment for "I Couldn't Upload Images Using Django Rest-framework"