Commit f549eb64 authored by Javi Ng's avatar Javi Ng

about to merge

parents 56f3a243 63f2825e
John Aidan Vincent Ng John Aidan Vincent Ng
214221 214221
CSCI40-C CSCI40-C
Lab 01: Song Library Lab 02: Song Library v2
February 13, 2023 February 20, 2023
I am Javi Ng and this lab was completed by me truthfully. I am Javi Ng and this lab was completed by me truthfully.
<sgd> John Aidan Vincent Martinez Ng, 02/13/2023 <sgd> John Aidan Vincent Martinez Ng, 02/20/2023
\ No newline at end of file \ No newline at end of file
No preview for this file type
from django.contrib import admin from django.contrib import admin
from .models import Artist, Album, Song
# Register your models here. # Register your models here.
# Admin page for Artist model
class ArtistAdmin(admin.ModelAdmin):
model = Artist
# list artist name, birth name, monthly listeners
list_display = ("artist_name", "birth_name", "monthly_listeners")
# search and filter by artist name, birth name
search_fields = ("artist_name", "birth_name")
list_filter = ("artist_name", "birth_name")
# Admin page for Album model
class AlbumAdmin(admin.ModelAdmin):
model = Album
# list artist name, birth name, monthly listeners
list_display = ("album_name", "description", "release_date", "label", "song_count")
# search by album name, description or label
search_fields = ("album_name", "description", "label")
# filter by album name
list_filter = ("album_name",)
# Admin page for Artist model
class SongAdmin(admin.ModelAdmin):
model = Song
# list song title, song length, lyrics, whether or not it has music video
list_display = ("song_title", "song_length", "lyrics", "music_video")
# search by song title, lyrics
search_fields = ("song_title", "lyrics")
# filter by song title
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
# Generated by Django 3.2 on 2023-02-20 05:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='album',
name='label',
field=models.CharField(default='', max_length=100),
),
migrations.AddField(
model_name='album',
name='song_count',
field=models.CharField(default=0, max_length=50),
),
migrations.AddField(
model_name='artist',
name='bio',
field=models.CharField(default='', max_length=700),
),
migrations.AddField(
model_name='artist',
name='birth_name',
field=models.CharField(default='', max_length=100),
),
migrations.AddField(
model_name='song',
name='lyrics',
field=models.CharField(default='', max_length=1000),
),
migrations.AddField(
model_name='song',
name='music_video',
field=models.BooleanField(default=False),
),
]
...@@ -4,15 +4,30 @@ from django.db import models ...@@ -4,15 +4,30 @@ from django.db import models
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(default = 0) monthly_listeners = models.IntegerField(default = 0)
birth_name = models.CharField(max_length = 100, default = "")
bio = models.CharField(max_length = 700, default = "")
def __str__(self):
return self.artist_name
class Album(models.Model): class Album(models.Model):
album_name = models.CharField(max_length = 100) album_name = models.CharField(max_length = 100)
artist = models.ForeignKey(Artist, on_delete = models.CASCADE) artist = models.ForeignKey(Artist, on_delete = models.CASCADE)
description = models.CharField(max_length = 500) description = models.CharField(max_length = 500)
label = models.CharField(max_length = 100, default = "")
song_count = models.CharField(max_length = 50, default = 0)
release_date = models.DateTimeField("Date Released") release_date = models.DateTimeField("Date Released")
def __str__(self):
return self.album_name
class Song(models.Model): class Song(models.Model):
song_title = models.CharField(max_length = 100) song_title = models.CharField(max_length = 100)
artist = models.ForeignKey(Artist, on_delete = models.CASCADE) artist = 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(default = 0) lyrics = models.CharField(max_length = 1000, default = "")
\ No newline at end of file song_length = models.IntegerField(default = 0)
music_video = models.BooleanField(default = False)
def __str__(self):
return self.song_title
SECRET_KEY = "django-insecure--s*^ukg&imwq7bq%$ea4w4!#v&11@5@y*4njh(nr($17(oml8!"
\ No newline at end of file
...@@ -11,6 +11,11 @@ https://docs.djangoproject.com/en/3.2/ref/settings/ ...@@ -11,6 +11,11 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
""" """
from pathlib import Path from pathlib import Path
from dotenv import load_dotenv
import os
# loading env file
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
...@@ -20,7 +25,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent ...@@ -20,7 +25,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure--s*^ukg&imwq7bq%$ea4w4!#v&11@5@y*4njh(nr($17(oml8!' SECRET_KEY = "django-insecure--s*^ukg&imwq7bq%$ea4w4!#v&11@5@y*4njh(nr($17(oml8!"
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
......
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