Music is the key

Report a typo

Below, we created the Album model.

class Album(models.Model):
    title = models.CharField(max_length=30)
    artist = models.CharField(max_length=30)
    genre = models.CharField(max_length=30)

We then used the model to populate the database with well-known albums of famous rock bands from this dictionary:

artists = {
    'Beatles': ['Revolver', "Sgt Pepper's Lonely Hearts Club Band", 'The Beatles (The White Album)', 'Abbey Road', 'Rubber Soul'], 
    'Rolling Stones': ['Exile On Main Street', 'Sticky Fingers'], 
    'Clash ': ['London Calling'],
    'Smashing Pumpkins': ['Mellon Collie And The Infinite Sadness', 'Siamese Dream']
}

We would like you to write ORM queries to perform some operations on the database. Like so:

  1. Filter all the albums from Beatles;
  2. Insert the Nirvana artist into the database with the album Nevermind and the genre is rock;
  3. Retrieve all artists, excluding Nirvana;
  4. Delete the Siamese Dream album from Smashing Pumpkins.

You don't need to print or retrieve something, just write the correct queries.

Write a program in Python 3
beatles_albums = ...
create_nirvana = ..
artists_exclude_nirvana = ...
del_smashing_pumpkins = ...
___

Create a free account to access the full topic