Reputation: 63
I am new to Django and I have not had any luck trying to troubleshoot this issue. What I want is a list of songs that will display the songName, artist and album, but what I am getting is the single column unicode display that is the default in Django admin. Below is my relevant source code. Thank you.
##models.py##
class Artist(models.Model):
artistName = models.CharField(max_length = 30)
artistInfo = models.TextField()
def __unicode__(self):
return self.artistName
class Album(models.Model):
albumName = models.CharField(max_length = 30)
artist = models.ForeignKey('Artist')
date = models.DateTimeField('Release Date')
albumInfo = models.TextField()
def __unicode__(self):
return self.albumName
class Song(models.Model):
songName = models.CharField(max_length = 30)
artist = models.ForeignKey('Artist')
album = models.ForeignKey('Album')
def __unicode__(self)
return self.songName
##admin.py##
from django.contrib import admin
from radio.models import Artist, Album, Song
class SongAdmin(admin.ModelAdmin):
list_display = ('songName', 'artist', 'album')
admin.site.register(Song, SongAdmin)
admin.site.register(Artist)
admin.site.register(Album)
Upvotes: 1
Views: 64
Reputation: 397
Your code is 100% correct, you should see 3 columns.
P.S.: You've missed out the ":" after def __unicode__(self):
in your Song
class
Upvotes: 2