Read the guideline before starting.
In db/models.py
create table Genre
with such fields:
- char field
name
, name of the genre with the maximum length of 255 characters.
Also, create table Actor
with such fields:
- char field
first_name
, name of the actor with the maximum length of 255 characters; - char field
last_name
, surname of the actor with the maximum length of 255 characters.
Inside main.py
, create main
function.
This function should perform these actions:
- Create:
- genre Western
- genre Action
- genre Dramma
- actor George Klooney
- actor Kianu Reaves
- actress Scarlett Keegan
- actor Will Smith
- actor Jaden Smith
- actress Scarlett Johansson
- Update:
- genre Dramma, set
name
to "Drama" - actor George Klooney, set
last_name
to "Clooney" - actor Kianu Reaves, set
first_name
to "Keanu" andlast_name
to "Reeves"
- genre Dramma, set
- Delete:
- genre Action
- all actresses with the
first_name
"Scarlett"
- Return:
- QuerySet of actors with
last_name
"Smith" and ordered byfirst_name
- QuerySet of actors with
Note: if you need to sort the QuerySet, you can use .order_by() method
Example:
print(main())
# <QuerySet [<Actor: Jaden Smith>, <Actor: Will Smith>]>
print(Genre.objects.all())
# <QuerySet [<Genre: Western>, <Genre: Drama>]>
print(Actor.objects.all())
# <QuerySet [<Actor: George Clooney>, <Actor: Keanu Reeves>, <Actor: Will Smith>, <Actor: Jaden Smith>]>