Commit 1bf75cc2 authored by Stefan Gomez's avatar Stefan Gomez

Updated the admin.py of the Homepage with required customizations.

parent b42e63a3
...@@ -3,12 +3,21 @@ from .models import Artist, Album, Song ...@@ -3,12 +3,21 @@ from .models import Artist, Album, Song
class ArtistAdmin(admin.ModelAdmin): class ArtistAdmin(admin.ModelAdmin):
model = Artist 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): class AlbumAdmin(admin.ModelAdmin):
model = Album 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): class SongAdmin(admin.ModelAdmin):
model = Song 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(Artist, ArtistAdmin)
......
# Generated by Django 4.1.7 on 2023-02-21 10:22
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.TextField(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),
),
migrations.AlterField(
model_name='album',
name='album_name',
field=models.CharField(max_length=100, null=True),
),
migrations.AlterField(
model_name='album',
name='description',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='album',
name='release_date',
field=models.CharField(max_length=100, null=True),
),
migrations.AlterField(
model_name='artist',
name='artist_name',
field=models.CharField(max_length=100, null=True),
),
migrations.AlterField(
model_name='artist',
name='monthly_listeners',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='song',
name='song_length',
field=models.IntegerField(null=True),
),
migrations.AlterField(
model_name='song',
name='song_title',
field=models.CharField(max_length=100, null=True),
),
]
from django.db import models from django.db import models
class Artist(models.Model): class Artist(models.Model):
artist_name = models.CharField(max_length=100) artist_name = models.CharField(max_length=100, null=True)
monthly_listeners = models.IntegerField() monthly_listeners = models.IntegerField(null=True)
birth_name = models.CharField(max_length=100) birth_name = models.CharField(max_length=100, null=True)
bio = models.TextField(max_length=700) bio = models.TextField(max_length=700, null=True)
class Album(models.Model): class Album(models.Model):
album_name = models.CharField(max_length=100) album_name = models.CharField(max_length=100, null=True)
artist = models.ForeignKey( artist = models.ForeignKey(
Artist, Artist,
on_delete=models.CASCADE on_delete=models.CASCADE
) )
description = models.TextField() description = models.TextField(null=True)
release_date = models.CharField(max_length=100) release_date = models.CharField(max_length=100, null=True)
label = models.CharField(max_length=100) label = models.CharField(max_length=100, null=True)
song_count = models.IntegerField() song_count = models.IntegerField(null=True)
class Song(models.Model): class Song(models.Model):
song_title = models.CharField(max_length=100) song_title = models.CharField(max_length=100, null=True)
artist = models.ForeignKey( artist = models.ForeignKey(
Artist, Artist,
on_delete=models.CASCADE on_delete=models.CASCADE
...@@ -27,6 +27,6 @@ class Song(models.Model): ...@@ -27,6 +27,6 @@ class Song(models.Model):
Album, Album,
on_delete=models.CASCADE on_delete=models.CASCADE
) )
song_length = models.IntegerField() song_length = models.IntegerField(null=True)
music_video = models.BooleanField() music_video = models.BooleanField(null=True)
lyrics = models.TextField() lyrics = models.TextField(null=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