Commit 49afebd6 authored by Nicholo Pardines's avatar Nicholo Pardines

Added sensible string representations to the homepage models, improved admin panel usability

parent e4aecfb9
......@@ -5,11 +5,13 @@ from .models import Song, Album, Artist
class SongAdmin(admin.ModelAdmin):
model = Song
list_display = ('song_title', 'song_length', 'lyrics', 'music_video')
fields = ('song_title', 'song_length', 'lyrics', 'music_video',)
fields = ('song_title', 'song_length', 'lyrics', 'music_video', 'artist')
search_fields = ('song_title', 'lyrics')
list_filter = ('song_title',)
class ArtistAdmin(admin.ModelAdmin):
def __str__(self) -> str:
return Artist.artist_name
model = Artist
fields = ('artist_name','birth_name','monthly_listeners', 'bio',)
list_display = ('artist_name','birth_name','monthly_listeners')
......
......@@ -17,12 +17,16 @@ from django.db import models
# * album
# * song_length
class Artist(models.Model):
def __str__(self) -> str:
return self.artist_name
artist_name = models.CharField(max_length=50, default="")
birth_name = models.CharField(max_length=50, default="")
bio = models.CharField(max_length=700, default="")
monthly_listeners = models.IntegerField(default=0)
class Album(models.Model):
def __str__(self) -> str:
return self.album_name
album_name = models.CharField(max_length=50)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE, default=None, null=True, blank=True)
description = models.CharField(max_length=50)
......@@ -31,6 +35,8 @@ class Album(models.Model):
song_count = models.IntegerField(default=0)
class Song(models.Model):
def __str__(self) -> str:
return self.song_title
song_title = models.CharField(max_length=50, default="")
artist = models.ForeignKey(Artist, on_delete=models.CASCADE, default=None, null=True, blank=True)
album = models.ForeignKey(Album, on_delete=models.CASCADE, default=None, null=True, blank=True)
......
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