Commit 6908d17b authored by Deokhyun Lee's avatar Deokhyun Lee

Merge branch 'lab02' into 'main'

Lab02

See merge request !1
parents 4eb98b7c b8154075
File added
......@@ -21,7 +21,7 @@ from django.urls import include, path
# localhost:<port>/hompage
# localhost:<port>/about
# localhost:<port>/contact
# fo
urlpatterns = [
path('admin/', admin.site.urls),
path('homepage/', include('homepage.urls')),
......
Deokhyun Lee, 195736, BS CS, C
Lab 01 - Song Library
Feb 13, 2023.
Lab 02 - Song Library v2
Feb 21, 2023.
This lab work is done by me.
-by Deokhyun Lee, Feb 13, 2023.
\ No newline at end of file
-by Deokhyun Lee, Feb 21, 2023.
\ No newline at end of file
No preview for this file type
from django.contrib import admin
from .models import Artist, Album, Song
# Register your models here.
class ArtistAdmin(admin.ModelAdmin):
model = Artist
# for list_display
list_display = ('artist_name', 'birth_name', 'monthly_listeners')
# search_fields
search_fields = ('artist_name', 'birth_name')
# filtering
list_filter = ('artist_name', 'birth_name')
class AlbumAdmin(admin.ModelAdmin):
model = Album
# for list_display
list_display = ('album_name', 'description', 'release_date', 'label', 'song_count')
# search_fields
search_fields = ('album_name', 'description', 'label')
# filtering
list_filter = ('album_name',)
class SongAdmin(admin.ModelAdmin):
model = Song
# for list_display
list_display = ('song_title', 'song_length', 'lyrics', 'music_video')
# search_fields
search_fields = ('song_title', 'lyrics')
# filtering
list_filter = ('song_title',)
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
# Generated by Django 3.2 on 2023-02-13 08:48
# Generated by Django 3.2 on 2023-02-21 08:17
from django.db import migrations, models
import django.db.models.deletion
......@@ -20,6 +20,8 @@ class Migration(migrations.Migration):
('artist', models.CharField(max_length=50)),
('description', models.CharField(max_length=150)),
('release_date', models.DateTimeField(verbose_name='date published')),
('label', models.CharField(max_length=120)),
('song_count', models.IntegerField()),
],
),
migrations.CreateModel(
......@@ -28,6 +30,8 @@ class Migration(migrations.Migration):
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('artist_name', models.CharField(max_length=50)),
('monthly_listeners', models.IntegerField()),
('birth_name', models.CharField(max_length=30)),
('bio', models.CharField(max_length=700)),
],
),
migrations.CreateModel(
......@@ -35,9 +39,11 @@ class Migration(migrations.Migration):
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('song_title', models.CharField(max_length=100)),
('artist', models.CharField(max_length=50)),
('song_length', models.IntegerField()),
('music_video', models.BooleanField()),
('lyrics', models.CharField(max_length=300)),
('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.album')),
('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.artist')),
],
),
]
......@@ -4,6 +4,8 @@ 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=30)
bio = models.CharField(max_length=700)
# for albums
class Album(models.Model):
......@@ -11,10 +13,16 @@ class Album(models.Model):
artist = models.CharField(max_length = 50)
description = models.CharField(max_length = 150)
release_date = models.DateTimeField("date published")
label = models.CharField(max_length=120)
song_count = models.IntegerField()
# for songs
class Song(models.Model):
song_title = models.CharField(max_length = 100)
artist = models.CharField(max_length = 50)
artist = models.ForeignKey(Artist, on_delete = models.CASCADE)
album = models.ForeignKey(Album, on_delete = models.CASCADE)
song_length = models.IntegerField()
music_video = models.BooleanField()
lyrics = models.CharField(max_length=300)
\ 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