Commit d53edff8 authored by Layla Mikel Villanueva's avatar Layla Mikel Villanueva

Merge branch 'lab02'

parents b01912a4 e1ca2144
* Layla Mikel Villanueva, 216288, BS CS-DGDD, CSCI 40-F * Layla Mikel Villanueva, 216288, BS CS-DGDD, CSCI 40-F
* Lab 01: Song Library * Lab 02: Song Library v2
* 13/02/2023 * 21/02/2023
* I have honestly followed and completed the instructions * I have honestly followed and completed the instructions
of the entire lab 01 all by myself. of the entire lab 02 all by myself.
* <sgd> Layla Mikel Villanueva, 13/02/2023 * <sgd> Layla Mikel Villanueva, 21/02/2023
\ No newline at end of file \ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import index
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
] ]
......
from django.contrib import admin from django.contrib import admin
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')
fieldsets = [
('Artist Information', {
'fields': [
('artist_name','birth_name'), 'monthly_ listeners', 'bio'
]
})
]
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',)
fieldsets = [
('Album Information', {
'fields': [
('album_name','artist'), ('release_date', 'song_count'), 'label', 'description'
]
})
]
class SongAdmin(admin.ModelAdmin):
model = Song
search_fields = ('song_title', 'lyrics')
list_display = ('song_title', 'song_length', 'lyrics', 'music_video')
list_filter=('song_title',)
fieldsets = [
('Song Information', {
'fields': [
('album','song_title'), 'artist', 'song_length', 'music_video', 'lyrics'
]
})
]
# Register your models here. # Register your models here.
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
# Generated by Django 4.1.6 on 2023-02-21 10:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_alter_artist_monthly_listeners'),
]
operations = [
migrations.AddField(
model_name='album',
name='label',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='album',
name='song_count',
field=models.IntegerField(default=1),
),
migrations.AddField(
model_name='artist',
name='bio',
field=models.CharField(blank=True, max_length=700, null=True),
),
migrations.AddField(
model_name='artist',
name='birth_name',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='song',
name='lyrics',
field=models.CharField(blank=True, max_length=30000, null=True),
),
migrations.AddField(
model_name='song',
name='music_video',
field=models.BooleanField(choices=[(False, 'does not have'), (True, 'has')], default=False, verbose_name='Music Video?'),
),
]
# Generated by Django 4.1.6 on 2023-02-21 10:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0003_album_label_album_song_count_artist_bio_and_more'),
]
operations = [
migrations.AlterField(
model_name='song',
name='lyrics',
field=models.TextField(blank=True, null=True),
),
]
# Generated by Django 4.1.6 on 2023-02-21 11:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0004_alter_song_lyrics'),
]
operations = [
migrations.AlterField(
model_name='song',
name='song_length',
field=models.DurationField(verbose_name='Song Length (in seconds)'),
),
]
# Generated by Django 4.1.6 on 2023-02-21 11:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0005_alter_song_song_length'),
]
operations = [
migrations.AlterField(
model_name='album',
name='description',
field=models.TextField(),
),
]
# Generated by Django 4.1.6 on 2023-02-21 11:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0006_alter_album_description'),
]
operations = [
migrations.AlterField(
model_name='song',
name='music_video',
field=models.BooleanField(default=False, verbose_name='Music Video?'),
),
]
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class Artist(models.Model): class Artist(models.Model):
artist_name = models.CharField(max_length=255, unique=True) artist_name = models.CharField(max_length=255, unique=True)
monthly_listeners = models.IntegerField() monthly_listeners = models.IntegerField()
birth_name = models.CharField(max_length=255, blank=True, null=True)
bio = models.CharField(max_length=700, blank=True, null=True)
def __str__(self): def __str__(self):
return '{} - {} monthly listeners'.format(self.artist_name,self.monthly_listeners) return '{}'.format(self.artist_name)
def get_absolute_url(self): def get_absolute_url(self):
return reverse('artist_detail', args=[str(self.artist_name)]) return reverse('artist_detail', args=[str(self.artist_name)])
...@@ -15,25 +18,29 @@ class Artist(models.Model): ...@@ -15,25 +18,29 @@ class Artist(models.Model):
class Album(models.Model): class Album(models.Model):
album_name = models.CharField(max_length=255) album_name = models.CharField(max_length=255)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
description = models.CharField(max_length=999) description = models.TextField()
release_date = models.DateField() release_date = models.DateField()
label = models.CharField(max_length=255, blank=True, null=True)
song_count = models.IntegerField(default=1)
def __str__(self): def __str__(self):
return '{} by {} released on {} is {}'.format(self.album_name,self.artist, return '{}'.format(self.album_name)
self.release_date,self.description)
def get_absolute_url(self): def get_absolute_url(self):
return reverse('album_detail', args=[str(self.album_name)]) return reverse('album_detail', args=[str(self.album_name)])
class Song(models.Model): class Song(models.Model):
song_title = models.CharField(max_length=255) song_title = models.CharField(max_length=255)
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.DurationField() song_length= models.DurationField()
music_video = models.BooleanField(verbose_name="Music Video?", default=False )
lyrics = models.TextField(blank=True, null=True)
def __str__(self): def __str__(self):
return '{} by {} from {} is {} long.'.format(self.song_title,self.artist, return '{}'.format(self.song_title)
self.album,self.song_length)
def get_absolute_url(self): def get_absolute_url(self):
return reverse('song_detail', args=[str(self.song_title)]) return reverse('song_detail', args=[str(self.song_title)])
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