I am trying to add a filefield in my django models but I am not sure how to handle the files coming from React Front-end.
Models.py
class Product(models.Model):
name = models.CharField(max_length=500, default=0)
short_code = models.CharField(max_length=500, default=0,unique=True)
document = models.FileField(upload_to='products/', null=True, blank=True)
owner = models.ForeignKey(User, on_delete=models.CASCADE)
Serializer.py
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = "__all__"
When the File is uploaded from Frontend it gives the following error in Network
{"detail":"Unsupported media type "multipart/form-data boundary=967753268136369" in request."}
I have gone through the documentation of DRF and I am sure I need to implement MultiParser in it but I am not sure how. Also Is there a better way to handle "File Handling"? I am using Ant Design File Upload in the application