I have a news model with an image, and this news can be downloaded via the JSON REST API. The server is signed with a certificate from the Authority, and all requests must be performed using https.
My problem is that ModelSerializer serializes ImageField with http, not https. How to change this?
Here is a summary of sample code and output:
class News(models.Model):
image = models.ImageField()
class NewsSerializer(serializers.ModelSerializer):
class Meta:
model = News
fields = ('image')
https://myDomain/news/the-news-id-here/
{
"image": "http://myDomain/media/news/imageName.jpg"
}
{
"image": "https://myDomain/media/news/imageName.jpg"
}
Thanks david
source
share