This API will allow developers to build applications that recommend songs based on a provided genre. It will manage artists, songs produced by those artists, and the genre for each song.
We'll make millions 💰 💰 💰
There is no authentication needed for this API, so make sure that in your settings.py
module that the following AllowAny
setting exists for default persmissions.
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.AllowAny',
],
}
When you are done building this project, let one of your coaches know and be prepared to discuss the following learning objectives so that you can ensure that your vocabulary is solid.
- Understand and explain what a database model is.
- Understand and explain what a view is.
- Understand and explain what serializer is.
- Understand and explain how to expose routes in your API.
- Understand and explain how the
related_name
attribute works on database models. - Understand and explain a custom property on a model.
- Understand and explain how to use the ORM to get all rows from a table.
- Understand and explain how to use the ORM to get single rows from a table.
- Understand and explain how to use the ORM to get some rows from a table with a filter.
- Understand and explain how to access request body data.
- Understand and explain how to access URL query parameters.
- Be able to load data from a fixture.
- Clone the template repository
cd
to the directory it createspipenv shell
pipenv install
- Open in VS Code
- Make sure the correct interpreter is selected
- Implement the code
- Create a new song
- List all songs with genre and artist information embedded
- Get a single song with genre and artist information embedded
- List songs assigned to a specific genre
- List songs assigned to a specific artist
- Create a new artist
- Get a single artist.
- List all artists.
The artist response should include the total number of songs in the database for the artist. It should also include a serialized list of all related songs (see example below).
The following information should be captured for each artist.
- Name
- Age
- Bio
The following information should be captured for each song.
- Title
- Artist
- Genre
- Album name
- Length
The genre model only needs to have the name of the genre on it.
Set up your serializers to produce the following JSON responses for getting songs and artists.
{
"id": 1,
"title": "Song Title",
"album": "Album Title",
"length": 342,
"genre": {
"description": "Pop"
},
"artist": {
"name": "Yerena Gonzalez"
}
}
{
"id": 1,
"name": "Yerena Gonzalez",
"age": 26,
"bio": "Accusamus maxime sed illo doloribus minus. Quaerat et sed et. Harum consequatur hic ut magnam consequatur labore culpa tempore.",
"songs": [
{
"id": 1,
"title": "Song Title",
"album": "Album Title"
}
],
"song_count": 1
}