我是 Django 的新手,我没有任何运气尝试解决这个问题。我想要的是显示歌曲名称、艺术家和专辑的歌曲列表,但我得到的是 Django 管理中默认的单列 unicode 显示。以下是我的相关源代码。谢谢你。
##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)