From 19ec03f44d6ef1bf4458c7b7c172c15b789eaa66 Mon Sep 17 00:00:00 2001 From: rivrxsq Date: Sun, 12 Jan 2025 01:27:49 +0200 Subject: [PATCH] add urls --- ...emahall_genre_movie_actors_movie_genres.py | 47 +++++++++++++++++++ cinema/urls.py | 30 ++++++++---- 2 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 cinema/migrations/0002_actor_cinemahall_genre_movie_actors_movie_genres.py diff --git a/cinema/migrations/0002_actor_cinemahall_genre_movie_actors_movie_genres.py b/cinema/migrations/0002_actor_cinemahall_genre_movie_actors_movie_genres.py new file mode 100644 index 000000000..cd35e55f0 --- /dev/null +++ b/cinema/migrations/0002_actor_cinemahall_genre_movie_actors_movie_genres.py @@ -0,0 +1,47 @@ +# Generated by Django 4.1 on 2025-01-11 22:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cinema', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Actor', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=255)), + ('last_name', models.CharField(max_length=255)), + ], + ), + migrations.CreateModel( + name='CinemaHall', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('rows', models.IntegerField()), + ('seats_in_row', models.IntegerField()), + ], + ), + migrations.CreateModel( + name='Genre', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255, unique=True)), + ], + ), + migrations.AddField( + model_name='movie', + name='actors', + field=models.ManyToManyField(to='cinema.actor'), + ), + migrations.AddField( + model_name='movie', + name='genres', + field=models.ManyToManyField(to='cinema.genre'), + ), + ] diff --git a/cinema/urls.py b/cinema/urls.py index 74e81ba34..453f524e6 100644 --- a/cinema/urls.py +++ b/cinema/urls.py @@ -1,13 +1,25 @@ -from django.urls import path, include -from rest_framework import routers +from django.urls import path +from rest_framework.routers import DefaultRouter +from cinema.views import ( + MovieViewSet, + GenreList, + GenreDetail, + CinemaHallList, + CinemaHallDetail, + ActorList, + ActorDetail +) -from cinema.views import MovieViewSet +router = DefaultRouter() +router.register("movies", MovieViewSet, basename="movie") -router = routers.DefaultRouter() -router.register("buses", MovieViewSet) +app_name = "cinema" urlpatterns = [ - path("", include(router.urls)), -] - -app_name = "cinema" + path("genres/", GenreList.as_view(), name="genre-list"), + path("genres//", GenreDetail.as_view(), name="genre-detail"), + path("actors/", ActorList.as_view(), name="actor-list"), + path("actors//", ActorDetail.as_view(), name="actor-detail"), + path("cinema_halls/", CinemaHallList.as_view(), name="actor-list"), + path("cinema_halls//", CinemaHallDetail.as_view(), name="actor-detail"), +] + router.urls \ No newline at end of file