I am using Django Rest Framework and have the following model:
class Picture(models.Model):
some_field = models.ForeignKey(some_model)
image = models
Updating the image field in the serializer to use_url=True worked for me:
class PictureSerialiser(serializers.ModelSerializer):
image = serializers.ImageField(
max_length=None, use_url=True
)
class Meta:
model = Picture
fields = ('field', 'image')
I wasn't able to get the currently accepted answer (adding a custom get_image_url method to the serializer) to work in Django 2.2. I was getting error messages that I needed to update my model to include the field image_url. Even after updating the model it wasn't working.