我的ImageField
模型中有一个带有默认图像的选项。我正在为模型 api 使用 Django Rest Framework。但是,当我尝试在没有图像的情况下发布(在浏览器外发布请求)时,我继续收到错误消息:No file was submitted. Check the encoding type on the form.
models.py
class Detector(models.Model):
average_image = models.ImageField(upload_to='average_image/',
default='average_image/default.png',
null=True, blank=True)
serializer.py
class DetectorSerializer(serializers.ModelSerializer):
class Meta:
model = Detector
fields = ('average_image')
views.py
class DetectorAPIList(generics.ListCreateAPIView):
serializer_class = DetectorSerializer
我错过了什么?
谢谢你的时间!