Commit d98df4ab authored by Mavrick Jordan Lee's avatar Mavrick Jordan Lee

Fixed admin.py and models.py

parent 5b4b9b50
No preview for this file type
...@@ -6,22 +6,22 @@ from .models import Artist, Album, Song ...@@ -6,22 +6,22 @@ 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', 'lyrics', 'music video flag') list_display = ('song_title', 'song_length', 'lyrics', 'music_video',)
search_fields = ('song title', 'lyrics') search_fields = ('song_title', 'lyrics',)
list_filter = ('song title') list_filter = ('song_title',)
admin.site.register(Artist) admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album) admin.site.register(Album, AlbumAdmin)
admin.site.register(Song) admin.site.register(Song, SongAdmin)
\ No newline at end of file \ No newline at end of file
...@@ -3,10 +3,13 @@ from django.db import models ...@@ -3,10 +3,13 @@ from django.db import models
# Create your models here. # Create your models here.
class Artist(models.Model): class Artist(models.Model):
artist_name = models.CharField(max_length=50) artist_name = models.CharField(max_length=50)
monthly_listeners = models.IntegerField() monthly_listeners = models.CharField(max_length=20)
birth_name = models.CharField(max_length=50) birth_name = models.CharField(max_length=50)
bio = models.CharField(max_length=700) bio = models.CharField(max_length=700)
def __str__(self):
return self.artist_name
class Album(models.Model): class Album(models.Model):
album_name = models.CharField(max_length=50) album_name = models.CharField(max_length=50)
artist_name = models.ForeignKey(Artist, on_delete=models.CASCADE) artist_name = models.ForeignKey(Artist, on_delete=models.CASCADE)
...@@ -15,10 +18,16 @@ class Album(models.Model): ...@@ -15,10 +18,16 @@ class Album(models.Model):
label = models.CharField(max_length=50) label = models.CharField(max_length=50)
song_count = models.IntegerField() song_count = models.IntegerField()
def __str__(self):
return self.album_name
class Song(models.Model): class Song(models.Model):
song_title = models.CharField(max_length=50) song_title = models.CharField(max_length=50)
artist_name = models.ForeignKey(Artist, on_delete=models.CASCADE) artist_name = models.ForeignKey(Artist, on_delete=models.CASCADE)
album = models.ForeignKey(Album, on_delete=models.CASCADE) album = models.ForeignKey(Album, on_delete=models.CASCADE)
song_length = models.IntegerField() song_length = models.CharField(max_length=5)
music_video = models.BooleanField() music_video = models.BooleanField()
lyrics = models.TextField() lyrics = models.TextField()
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