Skip to content

Commit

Permalink
add views, urls for Movie
Browse files Browse the repository at this point in the history
  • Loading branch information
b4oody committed Dec 28, 2024
1 parent d7fcfac commit f0fd6ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cinema/urls.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from django.urls import path
from django.urls import path, include
from rest_framework import routers

from cinema.views import (
GenreList,
GenreDetail,
ActorList,
ActorDetail,
CinemaHallViewSet,
MovieViewSet,
)

router = routers.DefaultRouter()
router.register("movies", MovieViewSet, basename="movies")

cinema_hall_list = CinemaHallViewSet.as_view(
actions={"get": "list",
Expand All @@ -25,16 +29,13 @@
path("genres/", GenreList.as_view(), name="genres-list"),
path("genres/<int:pk>/", GenreDetail.as_view(), name="genres-detail"),


path("actors/", ActorList.as_view(), name="actors-list"),
path("actors/<int:pk>/", ActorDetail.as_view(), name="actors-detail"),


path("cinema_halls/", cinema_hall_list, name="cinema-hall-list"),
path("cinema_halls/<int:pk>/", cinema_hall_detail, name="cinema-hall-detail"),



path("", include(router.urls)),

]

Expand Down
4 changes: 4 additions & 0 deletions cinema/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ class CinemaHallViewSet(
queryset = CinemaHall.objects.all()
serializer_class = CinemaHallSerializer


class MovieViewSet(viewsets.ModelViewSet):
queryset = Movie.objects.all()
serializer_class = MovieSerializer

0 comments on commit f0fd6ca

Please sign in to comment.