diff --git a/cinema/migrations/0001_initial.py b/cinema/migrations/0001_initial.py index 9cb1edef1..52772173a 100644 --- a/cinema/migrations/0001_initial.py +++ b/cinema/migrations/0001_initial.py @@ -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 @@ -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"), + ), ], ), ] diff --git a/cinema/models.py b/cinema/models.py index 7cbc8cf61..b9c07d629 100644 --- a/cinema/models.py +++ b/cinema/models.py @@ -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): @@ -23,8 +23,8 @@ 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): @@ -32,5 +32,5 @@ class CinemaHall(models.Model): 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}"