Commit 9f21c18a authored by EJ Mejilla's avatar EJ Mejilla

Updated homepage/models.py

parent be8d2e7f
...@@ -6,7 +6,9 @@ from django.urls import reverse ...@@ -6,7 +6,9 @@ from django.urls import reverse
class Artist(models.Model): class Artist(models.Model):
artist_name = models.CharField(max_length=100, unique=True) artist_name = models.CharField(max_length=100, unique=True)
monthly_listeners = models.IntegerField() monthly_listeners = models.IntegerField()
birth_name = models.CharField(max_length=100, unique=True)
bio = models.CharField(max_length=700)
def __str__(self): def __str__(self):
return self.artist_name return self.artist_name
...@@ -19,6 +21,8 @@ class Album(models.Model): ...@@ -19,6 +21,8 @@ class Album(models.Model):
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
description = models.CharField(max_length=500) description = models.CharField(max_length=500)
release_date = models.DateField() release_date = models.DateField()
label = models.CharField(max_length=100, unique=True)
song_count = models.IntegerField()
def __str__(self): def __str__(self):
return f"{self.artist}'s {self.album_name}" return f"{self.artist}'s {self.album_name}"
...@@ -26,11 +30,14 @@ class Album(models.Model): ...@@ -26,11 +30,14 @@ class Album(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('album_detail', args=[str(self.album_name)]) return reverse('album_detail', args=[str(self.album_name)])
class Song(models.Model): class Song(models.Model):
song_title = models.CharField(max_length=100, unique=True) song_title = models.CharField(max_length=100, unique=True)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
album = models.ForeignKey(Album, on_delete=models.CASCADE) album = models.ForeignKey(Album, on_delete=models.CASCADE)
song_length = models.IntegerField() song_length = models.IntegerField()
music_video = models.BooleanField()
lyrics = models.CharField()
def __str__(self): def __str__(self):
return f"{self.artist} - {self.song_title}" return f"{self.artist} - {self.song_title}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment