Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
rzaliznyi committed Dec 19, 2024
1 parent 5f33062 commit fc6c6d9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
18 changes: 18 additions & 0 deletions db/migrations/0002_rename_name_genre_genre.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.2 on 2024-12-19 21:29

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('db', '0001_initial'),
]

operations = [
migrations.RenameField(
model_name='genre',
old_name='name',
new_name='genre',
),
]
4 changes: 2 additions & 2 deletions db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


class Genre(models.Model):
name = models.CharField(max_length=255)
genre = models.CharField(max_length=255)

def __str__(self) -> str:
return self.name
return self.genre


class Actor(models.Model):
Expand Down
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


def main() -> QuerySet:
Genre.objects.create(name="Western")
Genre.objects.create(name="Action")
Genre.objects.create(name="Dramma")
Genre.objects.create(genre="Western")
Genre.objects.create(genre="Action")
Genre.objects.create(genre="Dramma")

Actor.objects.create(first_name="George", last_name="Klooney")
Actor.objects.create(first_name="Kianu", last_name="Reaves")
Expand All @@ -16,11 +16,11 @@ def main() -> QuerySet:
Actor.objects.create(first_name="Jaden", last_name="Smith")
Actor.objects.create(first_name="Scarlett", last_name="Johansson")

Genre.objects.filter(name="Dramma").update(genre="Drama")
Genre.objects.filter(genre="Dramma").update(genre="Drama")
Actor.objects.filter(last_name="Klooney").update(last_name="Clooney")
Actor.objects.filter(last_name="Keanu").update(last_name="Reeves")

Genre.objects.filter(name="Action").delete()
Genre.objects.filter(genre="Action").delete()
Actor.objects.filter(first_name="Scarlett").delete()

return Actor.objects.filter(last_name="Smith").order_by("first_name")

0 comments on commit fc6c6d9

Please sign in to comment.