bgneal@48: """ bgneal@48: Models for the mp3 application. bgneal@48: bgneal@48: """ bgneal@48: from django.db import models bgneal@48: bgneal@48: bgneal@48: class Collection(models.Model): bgneal@48: """ bgneal@48: This model represents a collection of songs. bgneal@48: bgneal@48: """ bgneal@48: title = models.CharField(max_length=64) bgneal@48: description = models.TextField() bgneal@48: date_added = models.DateTimeField() bgneal@48: bgneal@48: class Meta: bgneal@48: ordering = ['-date_added'] bgneal@48: bgneal@48: def __unicode__(self): bgneal@48: return self.title bgneal@48: bgneal@48: bgneal@48: class Song(models.Model): bgneal@48: """ bgneal@48: This model represents an uploaded song file. bgneal@48: bgneal@48: """ bgneal@48: title = models.CharField(max_length=64) bgneal@48: description = models.CharField(max_length=255, blank=True) bgneal@48: file = models.FileField(upload_to='mp3s/%Y/%m/%d/') bgneal@48: collection = models.ForeignKey(Collection) bgneal@48: bgneal@48: class Meta: bgneal@48: ordering = ['title'] bgneal@48: bgneal@48: def __unicode__(self): bgneal@48: return self.title bgneal@48: