Commit 015b04f9 authored by John Riz Daniel Ramos's avatar John Riz Daniel Ramos

Added Artist, Album, Song to Admin.py

parent ca9469e8
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', 'monthly_listeners')
class AlbumAdmin(admin.ModelAdmin):
model = Album
list_display = ('album_name', 'artist', 'description', 'release_date')
class SongAdmin(admin.ModelAdmin):
model = Song
list_display = ('song_title', 'artist', 'album', 'song_length')
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
\ No newline at end of file
# Generated by Django 3.2 on 2023-02-16 08:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='album',
name='artist',
field=models.CharField(max_length=50, unique=True),
),
migrations.AlterField(
model_name='album',
name='description',
field=models.CharField(max_length=150, unique=True),
),
migrations.AlterField(
model_name='artist',
name='artist_name',
field=models.CharField(max_length=50, unique=True),
),
migrations.AlterField(
model_name='song',
name='artist',
field=models.CharField(max_length=50, unique=True),
),
]
......@@ -2,26 +2,26 @@ from django.db import models
# Create your models here.
class Artist(models.Model):
artist_name = models.CharField(max_length=50)
artist_name = models.CharField(max_length=50, unique=True)
monthly_listeners = models.IntegerField()
def __str__(self):
return '{}: {} '.format(self.artist_name, self.monthly_listeners)
return '{}: {} monthly listeners'.format(self.artist_name, self.monthly_listeners)
class Album(models.Model):
album_name = models.CharField(max_length=50)
artist = models.CharField(max_length=50)
description = models.CharField(max_length=150)
artist = models.CharField(max_length=50, unique=True)
description = models.CharField(max_length=150, unique=True)
release_date = models.CharField(max_length=50)
def __str__(self):
return '{}: {} '.format(self.album_name, self.artist, self.description, self.release_date)
return '{} by {} | {} Released on {}'.format(self.album_name, self.artist, self.description, self.release_date)
class Song(models.Model):
song_title = models.CharField(max_length=50)
artist = models.CharField(max_length=50)
artist = models.CharField(max_length=50, unique=True)
album = models.CharField(max_length=150)
song_length = models.IntegerField()
def __str__(self):
return '{}: {} '.format(self.song_title, self.artist, self.album, self.song_length)
\ No newline at end of file
return '{} | {} | {} | {} secs.'.format(self.song_title, self.artist, self.album, self.song_length)
\ 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