I'm trying to set up my first Django application and I'm trying to
figure out the database relationships.  I want to be able to list
albums, with their corresponding tracks and album artwork.  Right now
I only have foreign keys defined in the Track class and on the
AlbumArt class pointing to the Album class.  I'm doing this so I can
keep a record of which track or which album art goes to which album.
However I also would like to add a ManyToManyField on my Album class
so I can pull the album data in my view.  Defining this is both places
seems redundant to me, but I'm not sure how else I can accomplish
this.  What would be best practice in this situation and how should I
proceed?

class Album(models.Model):
    title          = models.CharField(max_length=255)
    prefix         = models.CharField(max_length=20, blank=True)
    subtitle       = models.CharField(blank=True, max_length=255)
    slug           = models.SlugField(unique=True)
    artist         = models.ForeignKey('Artist')


class AlbumArt(models.Model):
    title          = models.CharField(max_length=200)
    slug           = models.SlugField()
    album          = models.ForeignKey('Album')


class Track(models.Model):
    title         = models.CharField(max_length=200)
    slug          = models.SlugField(unique=True)
    album         = models.ForeignKey('Album')
    artist        = models.ForeignKey('Artist')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to