With the Django Admin interface, how do you ensure that objects within HTML select multiple are sorted in some order (prefer alphabetical)? The issue is that I have 3 models - CD, Song, Singer. One the CD admin dashboard, Song is inline to CD and Singer is a manytomany field that I would like sorted!
My model.py
file:
class CD(models.Model):
cd_name = models.CharField("CD Name",max_length=50)
date = models.DateField("CD Release Date")
photo = models.ImageField("CD Cover",blank=True,upload_to='covers')
singers = models.ManyToManyField(Singer,blank=True,null=True)
def __unicode__(self):
return self.cd_name
class Song(models.Model):
cid = models.ForeignKey(CD)
track_num = models.PositiveIntegerField("Track Number",max_length=2)
song_name = models.CharField("Song Name",max_length=50)
soloists = models.ManyToManyField(Singer,blank=True,null=True)
stream_url = models.URLField("Stream URL", blank=True)
def __unicode__(self):
return self.song_name
class Singer(models.Model): (not relevent)
My admin.py
file:
class SongInline(admin.TabularInline):
model = Song
extra = 0
class CDAdmin(admin.ModelAdmin):
list_display = ('cd_name', 'date')
inlines = [
SongInline,
]
admin.site.register(CD, CDAdmin)