On 5/22/2009 5:31 PM, Patrick wrote: > What is the best way to make queries on a manytomany table? > > Given the models below, how can I get a list of all the songs a > particular artist has? > > class Artist(models.Model): > name = models.CharField(max_length=128) > > def __unicode__(self): > return u'%s' %(self.name) > > class Album(models.Model): > title = models.CharField(max_length=128) > artists = models.ManyToManyField(Artist) > > def __unicode__(self): > return u'%s' %(self.title) > > > class Song(models.Model): > title = models.CharField(max_length=128) > albums = models.ManyToManyField(Album) > > def __unicode__(self): > return self.title
Probably a compound query: 1. All albums for a given artist 2. All songs where albums in #1 -- George --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---