-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Artist, Album, Song models and update documentation
Models for Artist, Album, and Song have been included in the Django application inside the music app. The models were designed to carry out the required relationships in the music domain. Updated documentation to reflect the new additions and provided code examples for better understanding.
- Loading branch information
1 parent
c031890
commit f2a1ab5
Showing
2 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
class Artist(models.Model): | ||
name = models.CharField(max_length=100) | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
|
||
class Album(models.Model): | ||
title = models.CharField(max_length=100) | ||
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) | ||
release_year = models.IntegerField() | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
|
||
class Song(models.Model): | ||
author = models.CharField(max_length=100) | ||
title = models.CharField(max_length=100) | ||
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) # Artist or band name | ||
album = models.ForeignKey(Album, on_delete=models.CASCADE) # Album the song belongs to | ||
duration = models.IntegerField() # Duration of the song in seconds |