Skip to content

Commit

Permalink
Fix : 무조건 기본 URL만 반환하는 문제 수정정
Browse files Browse the repository at this point in the history
  • Loading branch information
joy-river committed Dec 29, 2024
1 parent 5303ba3 commit 3e4ccf3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions KUA/course/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,15 @@ def retrieve(self, request, *args, **kwargs):
"Authorization": f"Token {request.META.get('HTTP_AUTHORIZATION')}"
}
response = requests.get(api_url, headers=header)

if response.status_code == 200:
image_data = response.json()
if (image_data.get("image")):
profile_image_url = f"http://3.37.163.236:8000/{image_data['image']}"
except requests.exceptions.RequestException:
pass
if isinstance(image_data, list) and len(image_data) > 0:
first_item = image_data[0]
if "image" in first_item:
profile_image_url = f"http://3.37.163.236:8000{first_item['image']}"
except requests.exceptions.RequestException as e:
print(f"Request exception: {e}")


for post_image in post_images:
Expand Down

0 comments on commit 3e4ccf3

Please sign in to comment.