Commit e4aecfb9 authored by Nicholo Pardines's avatar Nicholo Pardines

Added filters and search to admin page, also fixed the default values for the homepage models.

parent ddfc944c
No preview for this file type
......@@ -4,5 +4,31 @@ from .models import Song, Album, Artist
class SongAdmin(admin.ModelAdmin):
model = Song
list_display = ('song_title', 'song_length', 'lyrics', 'music_video')
fields = ('song_title', 'song_length', 'lyrics', 'music_video',)
search_fields = ('song_title', 'lyrics')
list_filter = ('song_title',)
class ArtistAdmin(admin.ModelAdmin):
model = Artist
fields = ('artist_name','birth_name','monthly_listeners', 'bio',)
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
fields = ('album_name',
'description',
'release_date', 'label', 'song_count')
list_display = ('album_name',
'description',
'release_date', 'label', 'song_count')
search_fields = ('album_name', 'description', 'label',)
list_filter = ('album_name',)
admin.site.register(Song, SongAdmin)
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
# Generated by Django 4.1.6 on 2023-02-20 07:06
# Generated by Django 4.1.6 on 2023-02-20 08:28
from django.db import migrations, models
import django.db.models.deletion
......@@ -39,15 +39,15 @@ class Migration(migrations.Migration):
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('song_title', models.CharField(default='TBA', max_length=50)),
('song_length', models.IntegerField(default=0)),
('music_video', models.BooleanField(default='False')),
('music_video', models.BooleanField(default=False)),
('lyrics', models.TextField(default='TBA')),
('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.album')),
('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.artist')),
('album', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.album')),
('artist', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.artist')),
],
),
migrations.AddField(
model_name='album',
name='artist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.artist'),
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.artist'),
),
]
# Generated by Django 4.1.6 on 2023-02-20 08:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='album',
name='label',
field=models.CharField(default='', max_length=60),
),
migrations.AlterField(
model_name='artist',
name='artist_name',
field=models.CharField(default='', max_length=50),
),
migrations.AlterField(
model_name='artist',
name='bio',
field=models.CharField(default='', max_length=700),
),
migrations.AlterField(
model_name='artist',
name='birth_name',
field=models.CharField(default='', max_length=50),
),
migrations.AlterField(
model_name='song',
name='lyrics',
field=models.TextField(default=''),
),
migrations.AlterField(
model_name='song',
name='song_title',
field=models.CharField(default='', max_length=50),
),
]
......@@ -17,24 +17,24 @@ from django.db import models
# * album
# * song_length
class Artist(models.Model):
artist_name = models.CharField(max_length=50, default="TBA")
birth_name = models.CharField(max_length=50, default="TBA")
bio = models.CharField(max_length=700, default="TBA")
artist_name = models.CharField(max_length=50, default="")
birth_name = models.CharField(max_length=50, default="")
bio = models.CharField(max_length=700, default="")
monthly_listeners = models.IntegerField(default=0)
class Album(models.Model):
album_name = models.CharField(max_length=50)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE, default=None, null=True, blank=True)
description = models.CharField(max_length=50)
release_date = models.DateField()
label = models.CharField(max_length=60, default="TBA")
label = models.CharField(max_length=60, default="")
song_count = models.IntegerField(default=0)
class Song(models.Model):
song_title = models.CharField(max_length=50, default="TBA")
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
album = models.ForeignKey(Album, on_delete=models.CASCADE)
song_title = models.CharField(max_length=50, default="")
artist = models.ForeignKey(Artist, on_delete=models.CASCADE, default=None, null=True, blank=True)
album = models.ForeignKey(Album, on_delete=models.CASCADE, default=None, null=True, blank=True)
song_length = models.IntegerField(default=0)
music_video = models.BooleanField(default="False")
lyrics = models.TextField(default="TBA")
music_video = models.BooleanField(default=False)
lyrics = models.TextField(default="")
\ 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