I have a model News with an image and those News can be loaded via an JSON REST API. The server is signed with a certificate from an Authority and all request must be done with https.
My problem is, the ModelSerializer serialize the ImageField with http and not https. How do I change that ?
Here is an abstract of code and output example:
#myProject/models.py
class News(models.Model):
image = models.ImageField()
#myProject/serializers.py
class NewsSerializer(serializers.ModelSerializer):
class Meta:
model = News
fields = ('image')
#request for a news
https://myDomain/news/the-news-id-here/
#current output
{
"image": "http://myDomain/media/news/imageName.jpg"
}
#wanted output
{
"image": "https://myDomain/media/news/imageName.jpg"
}
Thanks David