Task 1
Task
For this task and the following ones, we'll try to build a music platform on which artists can sign up
and put up their albums for sale
-
Create a personal repository on GitLab called
django-training
-
Add mohamed.hashem bld.ai as maintainers to your repository (Project Information => Members => Invite members)
-
Create a Django project under the repository called
musicplatform
-
Create an app
artists
-
In
artists
Create anArtist
model with the following fields (make the right assumptions)
-
Stage name
-
required
-
unique
-
must be used as the model's default ordering
-
-
Social link field
-
This field is to store each artist's social media profile (e.g. https://www.instagram.com/drake/)
-
What is a suitable field for this type of data?
-
This field is optional, but it shouldn't be null (why?)
-
-
Create an app
albums
-
In
albums
, Create anAlbum
model with the following fields (you might think it's an overkill creating a whole app for one model, for the sake of this practice we could have added theAlbum
model to theartists
app, but in the real world, think of how your app will scale if there are multiple types of artists, each with its own model, for exampleGuestArtist
, and multiple types of albums, each with its own model)
-
an artist can have
0 or many
albums, an album must have an artist associated with it -
name (if name is not provided, it should be called
New Album
) -
creation datetime (the date when the album instance is created and stored in the database) (hint: respect the timezone)
-
release datetime which cannot be empty (hint: respect the timezone)
-
cost
- required
-
use what you find suitable between
FloatField
andDecimalField
-
Create a
RESULTS.md
undermusicplatform/
-
using
manage.py shell
(type the queries you used and their results inRESULTS.md
):
-
create some artists
-
list down all artists
-
list down all artists sorted by name
-
list down all artists whose name starts with
a
-
in 2 different ways, create some albums and assign them to any artists (hint: use
objects
manager and use the related object reference) -
get the latest released album
-
get all albums released before today
-
get all albums released today or before but not after today
-
count the total number of albums (hint: count in an optimized manner)
-
in 2 different ways, for each artist, list down all of his/her albums (hint: use
objects
manager and use the related object reference) -
list down all albums ordered by cost then by name (cost has the higher priority)