Commit 78436ed4 authored by Washington99's avatar Washington99

Included an str function

Fixes UI when displaying foreign keys available in the admin panel
parent 2b41d757
......@@ -7,6 +7,9 @@ class Artist(models.Model):
birth_name = models.CharField(max_length = 50, blank = True)
monthly_listeners = models.IntegerField()
bio = models.TextField(max_length = 700, blank = True)
def __str__(self):
return "{}".format(self.artist_name)
class Album(models.Model):
album_name = models.CharField(max_length = 50)
......@@ -16,6 +19,9 @@ class Album(models.Model):
label = models.CharField(max_length = 50, blank = True)
song_count = models.IntegerField(default = "0")
def __str__(self):
return "{}: {}".format(self.album_name, self.release_date)
class Song(models.Model):
song_title = models.CharField(max_length = 50)
artist = models.ForeignKey(Artist, on_delete = models.CASCADE)
......@@ -23,3 +29,6 @@ class Song(models.Model):
song_length = models.CharField(max_length = 10)
music_video = models.BooleanField(default = False)
lyrics = models.TextField(max_length = 1000, blank = True)
def __str__(self):
return "{} by {}".format(self.song_title, self.artist)
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