Skip to content

Commit

Permalink
feat: 이미지 생성 기능
Browse files Browse the repository at this point in the history
  • Loading branch information
Euizzang8001 committed Aug 17, 2024
1 parent 10dd183 commit df6339d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions KUA/student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,11 @@ def post(self, request, *args, **kwargs):
data = {
"name": name,
"tag": tag,
"image": image_uploads[0], # 이미지를 직렬화할 데이터에 포함시킴
}

serializer = self.get_serializer(data=data)
serializer.is_valid(raise_exception=True)
post = serializer.save()

# 이미지가 있을 경우 처리 (여기서 하나의 이미지만 처리)
image = image_uploads[0]
models.Image.objects.create(name=post.name, tag=post.tag, image=image)
serializer.save() # 이미지를 포함하여 저장

return Response(serializer.data, status=201)

0 comments on commit df6339d

Please sign in to comment.