Skip to content

Commit

Permalink
feat: 식당 상세정보
Browse files Browse the repository at this point in the history
  • Loading branch information
dkfla committed Jul 31, 2024
1 parent 1eb5bc3 commit cc0180e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions restaurants/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
views.add_remove_restaurant,
name="add-remove-restaurant",
),
path(
"restaurants/<int:pk>/detail", views.restaurant_detail, name="restaurant-detail"
),
path("restaurants/", views.user_restaurant_list, name="user-restaurant-list"),
]
13 changes: 13 additions & 0 deletions restaurants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit cc0180e

Please sign in to comment.