You need to use the build_absolute_uri. I do it the following way:
object_serialized = ModelSerializer(object)
object_data = object_serialized.data.copy()
if object_data['goal_image']:
object_data['goal_image'] = request.build_absolute_uri(
object.goal_image.url)
return Response(object_data)
If you share your code, we may be able to provide more accurate advise.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.