diff --git a/cinema/urls.py b/cinema/urls.py index a9e2ec93..8d97bf26 100644 --- a/cinema/urls.py +++ b/cinema/urls.py @@ -1,4 +1,5 @@ -from django.urls import path +from django.urls import path, include +from rest_framework import routers from cinema.views import ( GenreList, @@ -6,8 +7,11 @@ ActorList, ActorDetail, CinemaHallViewSet, + MovieViewSet, ) +router = routers.DefaultRouter() +router.register("movies", MovieViewSet, basename="movies") cinema_hall_list = CinemaHallViewSet.as_view( actions={"get": "list", @@ -25,16 +29,13 @@ path("genres/", GenreList.as_view(), name="genres-list"), path("genres//", GenreDetail.as_view(), name="genres-detail"), - path("actors/", ActorList.as_view(), name="actors-list"), path("actors//", ActorDetail.as_view(), name="actors-detail"), - path("cinema_halls/", cinema_hall_list, name="cinema-hall-list"), path("cinema_halls//", cinema_hall_detail, name="cinema-hall-detail"), - - + path("", include(router.urls)), ] diff --git a/cinema/views.py b/cinema/views.py index 5ff51da5..d1dda201 100644 --- a/cinema/views.py +++ b/cinema/views.py @@ -101,3 +101,7 @@ class CinemaHallViewSet( queryset = CinemaHall.objects.all() serializer_class = CinemaHallSerializer + +class MovieViewSet(viewsets.ModelViewSet): + queryset = Movie.objects.all() + serializer_class = MovieSerializer