Commit 648b937c authored by mantlei's avatar mantlei

Adding the modified models, the built Django Admin Panel, and the data population for the models

parent 72018c8f
from django.contrib import admin
# Register your models here.
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',)
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',)
class SongAdmin(admin.ModelAdmin):
model = Song
search_fields = ('song_title', 'lyrics',)
list_display = ('song_title', 'song_length', 'lyrics', 'music_video',)
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.7 on 2023-02-21 11:37
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(max_length=100, null=True),
),
migrations.AddField(
model_name='album',
name='song_count',
field=models.IntegerField(null=True),
),
migrations.AddField(
model_name='artist',
name='bio',
field=models.CharField(max_length=700, null=True),
),
migrations.AddField(
model_name='artist',
name='birth_name',
field=models.CharField(max_length=100, null=True),
),
migrations.AddField(
model_name='song',
name='lyrics',
field=models.TextField(null=True),
),
migrations.AddField(
model_name='song',
name='music_video',
field=models.BooleanField(null=True),
),
]
......@@ -4,6 +4,11 @@ from django.db import models
class Artist(models.Model):
artist_name = models.CharField(max_length=100)
monthly_listeners = models.IntegerField()
birth_name = models.CharField(max_length=100,null=True)
bio = models.CharField(max_length=700,null=True)
def __str__(self):
return f"{self.artist_name}"
class Album(models.Model):
......@@ -11,10 +16,19 @@ class Album(models.Model):
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
description = models.CharField(max_length=100)
release_date = models.DateField()
label = models.CharField(max_length=100,null=True)
song_count = models.IntegerField(null=True)
def __str__(self):
return f"{self.album_name}"
class Song(models.Model):
song_title = models.CharField(max_length=100)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
album = models.ForeignKey(Album, on_delete=models.CASCADE)
song_length = models.IntegerField()
music_video = models.BooleanField(null=True)
lyrics = models.TextField(null=True)
def __str__(self):
return f"{self.song_title}"
\ 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