Commit a712f07a authored by Alvin Joshua Andrada's avatar Alvin Joshua Andrada

built the admin panel and populated data

parent 42d15ae8
from django.contrib import admin 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 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 SongAdmin(admin.ModelAdmin):
model = Song
list_display = ('song_title', 'song_length','lyrics','music_video',)
search_fields = ('song_title', 'lyrics',)
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 4.1.6 on 2023-02-20 16:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0004_song_music_video'),
]
operations = [
migrations.AlterField(
model_name='album',
name='description',
field=models.CharField(max_length=300),
),
migrations.AlterField(
model_name='album',
name='release_date',
field=models.DateField(),
),
]
# Generated by Django 4.1.6 on 2023-02-20 16:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0005_alter_album_description_alter_album_release_date'),
]
operations = [
migrations.AlterField(
model_name='album',
name='release_date',
field=models.CharField(max_length=50),
),
]
# Generated by Django 4.1.6 on 2023-02-20 16:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0006_alter_album_release_date'),
]
operations = [
migrations.AlterField(
model_name='album',
name='release_date',
field=models.DateField(),
),
]
# Generated by Django 4.1.6 on 2023-02-20 17:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0007_alter_album_release_date'),
]
operations = [
migrations.AddField(
model_name='song',
name='length',
field=models.TimeField(default='00:03'),
preserve_default=False,
),
]
# Generated by Django 4.1.6 on 2023-02-20 17:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0008_song_length'),
]
operations = [
migrations.RemoveField(
model_name='song',
name='length',
),
migrations.AlterField(
model_name='song',
name='song_length',
field=models.CharField(max_length=50),
),
]
from django.db import models from django.db import models
#Referred to Django Documentation for Fields for Models
#https://docs.djangoproject.com/en/4.1/ref/models/fields/
class Artist(models.Model): class Artist(models.Model):
artist_name = models.CharField(max_length=100) artist_name = models.CharField(max_length=100)
monthly_listeners = models.IntegerField() monthly_listeners = models.IntegerField()
...@@ -9,8 +12,8 @@ class Artist(models.Model): ...@@ -9,8 +12,8 @@ class Artist(models.Model):
class Album(models.Model): class Album(models.Model):
album_name = models.CharField(max_length=50) album_name = models.CharField(max_length=50)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
description = models.IntegerField() description = models.CharField(max_length=300)
release_date = models.CharField(max_length=50) release_date = models.DateField()
label = models.CharField(max_length=100) label = models.CharField(max_length=100)
song_count = models.IntegerField() song_count = models.IntegerField()
...@@ -19,7 +22,6 @@ class Song(models.Model): ...@@ -19,7 +22,6 @@ class Song(models.Model):
song_title = models.CharField(max_length=50) song_title = models.CharField(max_length=50)
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() song_length = models.CharField(max_length=50)
music_video = models.BooleanField() music_video = models.BooleanField()
lyrics = models.CharField(max_length=3000) lyrics = models.CharField(max_length=3000)
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