diff --git a/db/models.py b/db/models.py index 137941ff..dc931c25 100644 --- a/db/models.py +++ b/db/models.py @@ -1 +1,10 @@ from django.db import models + + +class Genre(models.Model): + name = models.CharField(max_length=255) + + +class Actor(models.Model): + first_name = models.CharField(max_length=255) + last_name = models.CharField(max_length=255) diff --git a/main.py b/main.py index 545f938a..439e00b1 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,38 @@ from django.db.models import QuerySet +from db.models import Genre, Actor + def main() -> QuerySet: - pass + lists_genre = ["Western", "Action", "Dramma"] + lists_actor = [ + ("George", "Klooney"), + ("Kianu", "Reaves"), + ("Scarlett", "Keegan"), + ("Will", "Smith"), + ("Jaden", "Smith"), + ("Scarlett", "Johansson"), + ] + for genre in lists_genre: + Genre.objects.create(name=genre) + + for actor in lists_actor: + first_name, last_name = actor + Actor.objects.create(first_name=first_name, last_name=last_name) + + Genre.objects.filter(name="Dramma").update(name="Drama") + Actor.objects.filter(last_name="Klooney").update(last_name="Clooney") + Actor.objects.filter( + first_name="Kianu", + last_name="Reaves", + ).update(first_name="Keanu", last_name="Reeves") + + Genre.objects.filter(name="Action").delete() + + for actor in lists_actor: + first_name, last_name = actor + if first_name == "Scarlett": + Actor.objects.filter(first_name=first_name).delete() + + return Actor.objects.filter(last_name="Smith").all().order_by("first_name")