Commit d78fad94 authored by Ross Batacan's avatar Ross Batacan

Updated rossbatacan_music/homepage/models.py with __str__ functions and...

Updated rossbatacan_music/homepage/models.py with __str__ functions and changed Song model attribute lyrics_video to lyrics.
parent 2cacb2fe
...@@ -3,21 +3,21 @@ from .models import Artist, Album, Song ...@@ -3,21 +3,21 @@ from .models import Artist, Album, Song
class ArtistAdmin(admin.ModelAdmin): class ArtistAdmin(admin.ModelAdmin):
model = Artist model = Artist
list_display = ('artist_name', 'birth_name', 'monthly_listeners') list_display = ('artist_name', 'birth_name', 'monthly_listeners',)
search_fields = ('artist_name', 'birth_name') search_fields = ('artist_name', 'birth_name',)
list_filter = ('artist_name', 'birth_name') list_filter = ('artist_name', 'birth_name',)
class AlbumAdmin(admin.ModelAdmin): class AlbumAdmin(admin.ModelAdmin):
model = Album model = Album
list_display = ('album_name', 'description', 'release_date', 'label', 'song_count') list_display = ('album_name', 'description', 'release_date', 'label', 'song_count',)
search_fields = ('album_name', 'description', 'label') search_fields = ('album_name', 'description', 'label',)
list_filter = ('album_name') list_filter = ('album_name',)
class SongAdmin(admin.ModelAdmin): class SongAdmin(admin.ModelAdmin):
model = Song model = Song
list_display = ('song_title', 'song_length', 'music_video', 'lyrics_video') list_display = ('song_title', 'song_length', 'music_video', 'lyrics',)
search_fields = ('song_title', 'lyrics') search_fields = ('song_title', 'lyrics',)
list_filter = ('song_title') list_filter = ('song_title',)
admin.site.register(Artist, ArtistAdmin) admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin) admin.site.register(Album, AlbumAdmin)
......
...@@ -9,21 +9,32 @@ class Artist(models.Model): ...@@ -9,21 +9,32 @@ class Artist(models.Model):
birth_name = models.CharField(max_length=30, null=True) birth_name = models.CharField(max_length=30, null=True)
bio = models.CharField(max_length=250, null=True) bio = models.CharField(max_length=250, null=True)
def __str__(self):
return self.artist_name
class Album(models.Model): class Album(models.Model):
album_name = models.CharField(max_length=20, unique=True, null=True) album_name = models.CharField(max_length=20, unique=True, null=True)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE, null=True) artist = models.ForeignKey(Artist, on_delete=models.CASCADE, null=True)
description = models.CharField(max_length=100, null=True) description = models.CharField(max_length=250, null=True)
release_date = models.DateField(max_length=20, null=True) release_date = models.DateField(max_length=20, null=True)
label = models.CharField(max_length=100, null=True, blank=True) label = models.CharField(max_length=100, null=True, blank=True)
song_count = models.IntegerField(null=True) song_count = models.IntegerField(null=True)
def __str__(self):
return self.album_name
class Song(models.Model): class Song(models.Model):
song_title = models.CharField(max_length=50, null=True) song_title = models.CharField(max_length=50, null=True)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE, null=True) artist = models.ForeignKey(Artist, on_delete=models.CASCADE, null=True)
album = models.ForeignKey(Album, on_delete=models.CASCADE, null=True) album = models.ForeignKey(Album, on_delete=models.CASCADE, null=True)
song_length = models.IntegerField(null=True) song_length = models.IntegerField(null=True)
music_video = models.BooleanField(null=True) music_video = models.BooleanField(null=True)
lyrics_video = models.TextField(null=True) lyrics = models.TextField(null=True)
def __str__(self):
return 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