[英]The localhost address in front of the django image url
You need to use the build_absolute_uri.您需要使用 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.如果您分享您的代码,我们可能会提供更准确的建议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.