我有一个ImageField类型的模型:
class Attendance(models.Model):
face_image = models.ImageField(, blank=True, null=True, storage=MediaStorage())
基于模型的序列化程序
^{pr2}$但是,如果imagefield为空,则显示如下
Its now showing like this in the json
{
"id": 1,
"face_image": null
}
如果face_image(ImageField)的输出为空,则它将显示为空。我希望将null替换为如下空字符串“”
您可以使用SerializerMethodField。在
重写
AttendanceSerializer
的方法,更新(11/03/2019)
^{2}$序列化程序元中提到的所有字段的迭代代码:
相关问题 更多 >
编程相关推荐