Commit 6a1ab261 authored by Almira Redoble's avatar Almira Redoble

Created Artist, Album, Song Models in homepage app

parent 4529da67
from django.db import models from django.db import models
class Artist(models.Model):
artist_name = models.CharField(max_length=50)
monthly_listeners = models.IntegerField()
def __str__(self):
return '{}: {} monthly listener(s)'.format(
self.artist_name,
self.monthly_listeners
)
class Album(models.Model):
album_name = models.CharField(max_length=100)
artist = models.ForeignKey(
Artist,
on_delete=models.CASCADE,
related_name='album'
)
description = models.CharField(max_length=100)
release_date = models.DateField()
def __str__(self):
return '{} by {}: \n {} \n released on {}'.format(
self.album_name,
self.artist,
self.description,
self.release_date
)
class Song(models.Model):
song_title = models.CharField(max_length=50)
artist = models.ForeignKey(
Artist,
on_delete=models.CASCADE,
related_name='song'
)
album = models.ForeignKey(
Album,
on_delete=models.CASCADE,
related_name='song'
)
song_length = models.IntegerField()
def __str__(self):
return '{} by {} in {}'.format(
self.song_title,
self.artist,
self.album
)
# DateField source: https://www.geeksforgeeks.org/datefield-django-models/
# Create your models here. # Create your models here.
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