Skip to content

Commit

Permalink
edit models and migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
TsvetanKichuk committed Sep 29, 2024
1 parent 5e46010 commit f3e2b04
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 30 deletions.
81 changes: 59 additions & 22 deletions cinema/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1 on 2024-09-28 10:06
# Generated by Django 4.1 on 2024-09-28 18:31

from django.db import migrations, models

Expand All @@ -7,43 +7,80 @@ class Migration(migrations.Migration):

initial = True

dependencies = [
]
dependencies = []

operations = [
migrations.CreateModel(
name='Actor',
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)),
(
"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',
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()),
(
"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',
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)),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255, unique=True)),
],
),
migrations.CreateModel(
name='Movie',
name="Movie",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=255)),
('description', models.TextField()),
('duration', models.IntegerField()),
('actors', models.ManyToManyField(to='cinema.actor')),
('genres', models.ManyToManyField(to='cinema.genre')),
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=255)),
("description", models.TextField()),
("duration", models.IntegerField()),
(
"actors",
models.ManyToManyField(related_name="movies", to="cinema.actor"),
),
(
"genres",
models.ManyToManyField(related_name="movies", to="cinema.genre"),
),
],
),
]
16 changes: 8 additions & 8 deletions cinema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
class Genre(models.Model):
name = models.CharField(max_length=255, unique=True)

def __str__(self):
return self.name
def __str__(self) -> str:
return f"{self.name}"


class Actor(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)

def __str__(self):
return self.first_name, self.last_name
def __str__(self) -> str:
return f"{self.first_name}, {self.last_name}"


class Movie(models.Model):
Expand All @@ -23,14 +23,14 @@ class Movie(models.Model):
genres = models.ManyToManyField(Genre, related_name="movies")
actors = models.ManyToManyField(Actor, related_name="movies")

def __str__(self):
return self.title, self.description, self.duration, self.genres
def __str__(self) -> str:
return f"{self.title}, {self.description}, {self.duration}, {self.genres}"


class CinemaHall(models.Model):
name = models.CharField(max_length=255)
rows = models.IntegerField()
seats_in_row = models.IntegerField()

def __str__(self):
return self.name, self.rows, self.seats_in_row
def __str__(self) -> str:
return f"{self.name}, {self.rows}, {self.seats_in_row}"

0 comments on commit f3e2b04

Please sign in to comment.