Commit 31d64f33 authored by Alliyah Marcelo's avatar Alliyah Marcelo

Configured models to better visualize them in Django Admin.

parent fb7c8c6b
......@@ -3,16 +3,30 @@ from django.contrib import admin
from .models import Artist, Album, Song
class AlbumInline(admin.TabularInline):
model = Album
class SongInline(admin.TabularInline):
model = Song
class ArtistAdmin(admin.ModelAdmin):
model = Artist
list_display = (
'artist_name',
'birth_name',
'monthly_listeners',
)
list_display = ('artist_name', 'birth_name', 'monthly_listeners',)
search_fields = ('artist_name', 'birth_name',)
list_filter = ('artist_name', 'birth_name',)
inlines = [AlbumInline, SongInline,]
fieldsets = [
('Artist Data', {
'fields':[
('artist_name', 'birth_name'), 'monthly_listeners'
]
}),
]
class AlbumAdmin(admin.ModelAdmin):
model = Album
......
# Generated by Django 3.2 on 2023-02-21 06:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0006_alter_song_album'),
]
operations = [
migrations.AddField(
model_name='album',
name='label',
field=models.CharField(blank=True, max_length=50),
),
migrations.AddField(
model_name='album',
name='song_count',
field=models.IntegerField(default='0000000'),
),
migrations.AddField(
model_name='artist',
name='bio',
field=models.CharField(blank=True, max_length=700),
),
migrations.AddField(
model_name='artist',
name='birth_name',
field=models.CharField(blank=True, max_length=50),
),
migrations.AddField(
model_name='song',
name='lyrics',
field=models.CharField(blank=True, max_length=8000),
),
migrations.AddField(
model_name='song',
name='music_video',
field=models.BooleanField(default=True),
),
]
# Generated by Django 3.2 on 2023-02-21 06:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0007_auto_20230221_1408'),
]
operations = [
migrations.AlterField(
model_name='song',
name='music_video',
field=models.BooleanField(default=None),
),
]
from django.db import models
from django.urls import reverse
# Create your models here.
class Artist(models.Model):
artist_name = models.CharField(max_length=50)
monthly_listeners = models.IntegerField()
birth_name = models.CharField(max_length=50)
bio = models.CharField(max_length=700)
birth_name = models.CharField(max_length=50, blank=True)
bio = models.CharField(max_length=700, blank=True)
def __str__(self):
return '{}: {}'.format(self.artist_name, self.birth_name)
#def get_absolute_url(self):
#return reverse(admin('artist_detail', args=[str(self.artist_name)]))
@property
def is_tutorial(self):
return self.monthly_listeners == 1
class Album(models.Model):
......@@ -17,8 +29,18 @@ class Album(models.Model):
)
description = models.CharField(max_length=1000)
release_date = models.CharField(max_length=50)
label = models.CharField(max_length=50)
song_count = models.IntegerField()
label = models.CharField(max_length=50, blank=True)
song_count = models.IntegerField(default='0000000')
def __str__(self):
return '{}'.format(self.album_name)
#def get_absolute_url(self):
#return reverse(admin('artist_detail', args=[str(self.artist_name)]))
@property
def is_tutorial(self):
return self.song_count == 1
class Song(models.Model):
......@@ -34,5 +56,11 @@ class Song(models.Model):
related_name='song_album'
)
song_length = models.IntegerField()
music_video = models.BooleanField()
lyrics = models.CharField(max_length=8000)
music_video = models.BooleanField(default=None)
lyrics = models.CharField(max_length=8000, blank=True)
def __str__(self):
return '{} ({})'.format(self.song_title, self.song_length)
#def get_absolute_url(self):
#return reverse(admin('artist_detail', args=[str(self.artist_name)]))
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