From cc0180e43957894a2beae323b4c9352e1fd3abbb Mon Sep 17 00:00:00 2001 From: dkfla Date: Wed, 31 Jul 2024 20:09:14 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=8B=9D=EB=8B=B9=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=EC=A0=95=EB=B3=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- restaurants/urls.py | 3 +++ restaurants/views.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/restaurants/urls.py b/restaurants/urls.py index d91f411..3d5ce2d 100644 --- a/restaurants/urls.py +++ b/restaurants/urls.py @@ -11,5 +11,8 @@ views.add_remove_restaurant, name="add-remove-restaurant", ), + path( + "restaurants//detail", views.restaurant_detail, name="restaurant-detail" + ), path("restaurants/", views.user_restaurant_list, name="user-restaurant-list"), ] diff --git a/restaurants/views.py b/restaurants/views.py index 6c478b0..b7a578e 100644 --- a/restaurants/views.py +++ b/restaurants/views.py @@ -79,3 +79,16 @@ def add_remove_restaurant(request, pk): {"message": "Restaurant not found in your list"}, status=status.HTTP_404_NOT_FOUND, ) + + +@api_view(["GET"]) +@login_required +def restaurant_detail(request, pk): + try: + restaurant = Restaurant.objects.get(pk=pk) + serializer = RestaurantSerializer(restaurant) + return Response(serializer.data) + except Restaurant.DoesNotExist: + return Response( + {"message": "Restaurant not found"}, status=status.HTTP_404_NOT_FOUND + )