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:
- Filter all the albums from
Beatles; - Insert the
Nirvanaartist into the database with the albumNevermindand the genre isrock; - Retrieve all artists, excluding
Nirvana; - Delete the
Siamese Dreamalbum fromSmashing Pumpkins.
You don't need to print or retrieve something, just write the correct queries.