Skip to content

Commit

Permalink
add urls
Browse files Browse the repository at this point in the history
  • Loading branch information
rivrxsq committed Jan 11, 2025
1 parent 7ee71e5 commit 19ec03f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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'),
),
]
30 changes: 21 additions & 9 deletions cinema/urls.py
Original file line number Diff line number Diff line change
@@ -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/<int:pk>/", GenreDetail.as_view(), name="genre-detail"),
path("actors/", ActorList.as_view(), name="actor-list"),
path("actors/<int:pk>/", ActorDetail.as_view(), name="actor-detail"),
path("cinema_halls/", CinemaHallList.as_view(), name="actor-list"),
path("cinema_halls/<int:pk>/", CinemaHallDetail.as_view(), name="actor-detail"),
] + router.urls

0 comments on commit 19ec03f

Please sign in to comment.