Commit ee225008 authored by Mary Adelaide A. Salto's avatar Mary Adelaide A. Salto

Merge branch 'lab02'

parents 458c4d35 d67fb8e8
Mary Adelaide A. Salto, 215208, CSCI 40-F;
Lab 01: Song Library;
February 13, 2023;
This is to certify that the lab was truthfully completed by me;
<sgd> Mary Adelaide A. Salto, February 13, 2023
Lab 02: Song Library v2;
February 21, 2023;
This is to certify that the lab was truthfully completed by me
and I have not used Python language code from any unauthorized source;
<sgd> Mary Adelaide A. Salto, February 21, 2023
from django.contrib import admin
from .models import Artist, Album, Song
# Register your models here.
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,15 +3,30 @@ from django.db import models
class Artist(models.Model):
artist_name = models.CharField(max_length=50)
monthly_listeners = models.IntegerField()
birth_name = models.CharField(max_length=50, null=True)
bio = models.TextField(max_length=700, null=True)
def __str__(self):
return self.artist_name
class Album(models.Model):
album_name = models.CharField(max_length=50)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
description = models.CharField(max_length=200)
description = models.TextField(max_length=10000, null=True)
release_date = models.CharField(max_length=50)
label = models.CharField(max_length=50, null=True)
song_count = models.IntegerField(null=True)
def __str__(self):
return self.album_name
class Song(models.Model):
song_title = models.CharField(max_length=50)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
album = models.CharField(max_length=50)
song_length = models.IntegerField()
\ No newline at end of file
album = models.ForeignKey(Album, on_delete=models.CASCADE)
song_length = models.IntegerField()
music_video = models.BooleanField(null=True)
lyrics = models.TextField(max_length=5000, null=True)
def __str__(self):
return self.song_title
\ 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