[英]The localhost address in front of the django image url
您需要使用 build_absolute_uri。 我這樣做:
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)
如果您分享您的代碼,我們可能會提供更准確的建議。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.