Commit d4817dfa authored by Anthony Bicomong's avatar Anthony Bicomong

lab02 commit 1: update models

parent 6f0754b5
......@@ -2,6 +2,10 @@ BICOMONG, Anthony P.
ID# 210891
CSCI 40C
Lab 01: Song Library
13 February 2023
21 February 2023
I certify that this lab was truthfully completed by myself, Anthony Punzalan Bicomong.
<sgd> Anthony Punzalan Bicomong, 13 February 2023
\ No newline at end of file
<sgd> Anthony Punzalan Bicomong, 21 February 2023
Major Updates:
13 February 2023 - lab01 submission
21 February 2023 - lab02 specs implemented
\ No newline at end of file
......@@ -42,6 +42,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'homepage',
'about',
'contact',
]
MIDDLEWARE = [
......
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
list_display = ('artist_name', 'birth_name', 'monthly_listeners')
search_fields = ('artist_name', 'birth_name')
list_filter = ('artist_name', 'birth_name',)
class ArtistInline(admin.TabularInline):
model = Artist
class AlbumAdmin(admin.ModelAdmin):
model = Album
list_display = ('album_name', 'description', 'release_date', 'label', 'song_count')
search_fields = ('album_name', 'description', 'label')
list_filter = ('album_name',)
class AlbumInline(admin.TabularInline):
model = Album
class SongAdmin(admin.ModelAdmin):
model = Song
list_display = ('song_title', 'song_length', 'lyrics', 'music_video')
search_fields = ('song_title', 'lyrics')
list_filter = ('song_title',)
class SongInline(admin.TabularInline):
model = Song
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
\ No newline at end of file
# Generated by Django 4.1.6 on 2023-02-21 12:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_alter_album_artist'),
]
operations = [
migrations.AddField(
model_name='album',
name='label',
field=models.CharField(default='null', max_length=50),
preserve_default=False,
),
migrations.AddField(
model_name='album',
name='song_count',
field=models.IntegerField(default=123),
preserve_default=False,
),
migrations.AddField(
model_name='artist',
name='bio',
field=models.CharField(default='abc', max_length=700),
preserve_default=False,
),
migrations.AddField(
model_name='artist',
name='birth_name',
field=models.CharField(default='abcde', max_length=50),
preserve_default=False,
),
migrations.AddField(
model_name='song',
name='lyrics',
field=models.CharField(default='abcdefg', max_length=700),
preserve_default=False,
),
migrations.AddField(
model_name='song',
name='music_video',
field=models.IntegerField(default=1),
preserve_default=False,
),
]
......@@ -4,6 +4,8 @@ from django.urls import reverse
class Artist(models.Model):
artist_name = models.CharField(max_length=50)
monthly_listeners = models.IntegerField()
birth_name = models.CharField(max_length=50)
bio = models.CharField(max_length=700)
def __str__(self):
return '{}: {} monthly listener(s)'.format(self.artist_name, self.monthly_listeners)
......@@ -19,6 +21,8 @@ class Album(models.Model):
artist = models.ForeignKey(Artist, on_delete=models.CASCADE, related_name='album')
description = models.CharField(max_length=100)
release_date = models.IntegerField()
label = models.CharField(max_length=50)
song_count = models.IntegerField()
def __str__(self):
return self.album_name + " was created by " + self.artist.artist_name + ". Description: " + self.description + ". Released on " + str(self.release_date)
......@@ -34,6 +38,8 @@ class Song(models.Model):
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
album = models.ForeignKey(Album, on_delete=models.CASCADE)
song_length = models.IntegerField()
music_video = models.IntegerField()
lyrics = models.CharField(max_length=700)
def __str__(self):
return self.song_title + " was created by " + self.artist.artist_name + ", in their album, " + self.album.album_name + ". Song length: " + str(self.song_length)
......
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