Commit 35e67bb3 authored by Ysobel Vera's avatar Ysobel Vera

Modified models.py and built the Django Admin panel of the homepage app

Added extra attributes to models.py and built and customized the Django Admin panel to have search fields, list displays, and list filters for the Artist, Album, and Song classes
parent 34f2b82a
......@@ -3,9 +3,9 @@ Maria Ysobel Lourdes A. Vera
BS CS-DGDD
CSCI 40-F
Lab 01: Song Library
February 13, 2023
Lab 02: Song Library v2
February 21,2023
This lab has been truthfully completed by me.
sgd Maria Ysobel Lourdes A. Vera, February 13, 2023
sgd Maria Ysobel Lourdes A. Vera, February 21, 2023
No preview for this file type
from django.contrib import admin
# Register your models here.
from .models import Artist, Album, Song
class ArtistAdmin(admin.ModelAdmin):
model = Artist
search_fields = ('artist_name', 'birth_name',)
list_display = ('artist_name', 'birth_name', 'monthly_listeners',)
list_filter = ('artist_name', 'birth_name',)
class AlbumAdmin(admin.ModelAdmin):
model = Album
search_fields = ('album_name', 'description', 'label',)
list_display = ('album_name', 'description', 'release_date', 'label', 'song_count',)
list_filter = ('album_name',)
class SongAdmin(admin.ModelAdmin):
model = Song
search_fields = ('song_title', 'lyrics',)
list_display = ('song_title', 'song_length', 'lyrics', 'music_video',)
list_filter = ('song_title',)
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
\ No newline at end of file
......@@ -3,41 +3,36 @@ from django.urls import reverse
class Artist(models.Model):
artist_name = models.CharField(max_length=200,unique=True)
birth_name = models.CharField(max_length=200)
bio = models.CharField(max_length=700)
monthly_listeners = models.IntegerField()
"""
def __str__(self):
<<<<<<< Updated upstream
return '{} : {}'.format(self.artist_name, self.monthly_listeners)
"""
class Album(models.Model):
album_name = models.CharField(max_length=200)
artist = models.CharField(max_length=200)
label = models.CharField(max_length=700)
description = models.CharField(max_length=200)
song_count = models.IntegerField()
release_date = models.CharField(max_length=200)
"""
def __str__(self):
return '{} : {} : {} : {}'.format(self.album_name, self.artist,self.description,self.release_date)
=======
return '{}| {} listeners'.format(self.artist_name, self.monthly_listeners)
def get_absolute_url(self):
return reverse('artist_detail', args=[str(self.artist_name)])
class Album(models.Model):
album_name = models.CharField(max_length=200)
artist = models.ForeignKey(
Artist,
on_delete=models.CASCADE
)
description = models.CharField(max_length=200)
release_date = models.CharField(max_length=200)
>>>>>>> Stashed changes
"""
class Song(models.Model):
song_title = models.CharField(max_length=200)
artist = models.CharField(max_length=200)
album = models.CharField(max_length=200)
song_length = models.CharField(max_length=200)
music_video = models.BooleanField()
lyrics = models.CharField(max_length=10000)
"""
def __str__(self):
return '{} : {} : {} : {}'.format(self.song_title, self.artist,self.album,self.song_length)
\ No newline at end of file
return '{} : {} : {} : {}'.format(self.song_title, self.artist,self.album,self.song_length)
"""
\ No newline at end of file
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