From d6be83fdcd2348e4886d7b48546abefcdd839bb3 Mon Sep 17 00:00:00 2001 From: tkdwns414 Date: Thu, 17 Aug 2023 23:26:16 +0900 Subject: [PATCH] add BASE_IMAGE_URL in .env --- .env.example | 1 + backback/settings.py | 1 + community/serializers.py | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 01f8bde..3912ebc 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,7 @@ DEBUG= # Oauth BASE_URL= +BASE_IMAGE_URL= BASE_API_URL= GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= diff --git a/backback/settings.py b/backback/settings.py index 454c957..cc341c7 100644 --- a/backback/settings.py +++ b/backback/settings.py @@ -205,3 +205,4 @@ BASE_URL = os.getenv("BASE_URL") BASE_API_URL = os.getenv("BASE_API_URL") +BASE_IMAGE_URL = os.getenv("BASE_IMAGE_URL") diff --git a/community/serializers.py b/community/serializers.py index 63f6d03..7c05249 100644 --- a/community/serializers.py +++ b/community/serializers.py @@ -64,7 +64,7 @@ def get_image(self, instance): if instance.images.count() == 0: return None url = instance.images.first().image.url - return settings.BASE_URL + url # 밑이랑 달라요, url 쓰면 media 딸려서 나옴 + return settings.BASE_IMAGE_URL + url # 밑이랑 달라요, url 쓰면 media 딸려서 나옴 class PostDetailSerializer(serializers.ModelSerializer): @@ -109,7 +109,7 @@ def get_is_liked(self, instance): def get_images(self, obj): images = obj.images.all() image_urls = [ - settings.BASE_URL + settings.MEDIA_URL + str(image.image) + settings.BASE_IMAGE_URL + settings.MEDIA_URL + str(image.image) for image in images ] return image_urls