Commit d4e0f84b authored by Lay Villanueva's avatar Lay Villanueva

updated models.py

included Artist, Album, and Song classes for the database and its respective properties
parent c8121485
from django.db import models
# Create your models here.
class Artist(models.Model):
artist_name = models.CharField(max_length=255, unique=True)
monthly_listeners = models.IntegerField()
def __str__(self):
return '{} - {} monthly listeners'.format(self.artist_name,self.monthly_listeners)
class Album(models.Model):
album_name = models.CharField(max_length=255)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
description = models.CharField(max_length=999)
release_date = models.DateField()
def __str__(self):
return '{} by {} released on {} is {}'.format(self.album_name,self.artist,
self.release_date,self.description)
class Song(models.Model):
song_title = models.CharField(max_length=255)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
album = models.ForeignKey(Album, on_delete=models.CASCADE)
song_length = models.DurationField()
def __str__(self):
return '{} by {} from {} is {} long.'.format(self.song_title,self.artist,
self.album,self.song_length)
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