Commit bf41c49a authored by Joei Yucoco's avatar Joei Yucoco

Moved models to Homepage, configured admin panels and customized it

parent 2d3a8ded
No preview for this file type
from django.contrib import admin from django.contrib import admin
from .models import Artist, Album, Song
class ArtistAdmin(admin.ModelAdmin):
model = Artist
class AlbumAdmin(admin.ModelAdmin):
model = Album
class SongAdmin(admin.ModelAdmin):
model = Song
# registering the model and the admin is what tells
# Django that admin pages must be generated for the models specified
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
# Register your models here. # Register your models here.
from django.db import models from django.db import models
class Artist(models.Model): from .models import Artist, Album, Song
artist_name = models.CharField(max_length=100)
monthly_listeners = models.IntegerField()
birth_name = models.CharField(max_length=100)
bio = models.CharField(max_length=700)
class Album (models.Model): class ArtistAdmin(admin.ModelAdmin):
album_name = models.CharField(max_length=100) model = Artist
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) search_fields = ('artist_name', 'birth_name',)
description = models.CharField(max_length=500) list_display = ('artist_name', 'birth_name','monthly_listeners',)
release_date = models.DateField() list_filter = ('artsit_name', 'birth_name',)
label = models.CharField(max_length=100)
song_count = models.IntegerField() 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',)
# registering the model and the admin is what tells
# Django that admin pages must be generated for the models specified
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
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()
lyrics = models.CharField(max_length=5000)
# Create your models here. # Create your models here.
from django.db import models from django.db import models
class Artist(models.Model):
artist_name = models.CharField(max_length=100)
monthly_listeners = models.IntegerField()
birth_name = models.TextField()
bio = models.CharField(max_length=700)
class Album (models.Model):
album_name = models.CharField(max_length=100)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
description = models.TextField()
release_date = models.DateField()
label = models.CharField(max_length=100)
song_count = models.IntegerField()
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()
lyrics = models.TextField()
# Create your models here. # Create your models here.
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