what do you need the table songInstrument for?
i´d suggest using a many-to-many relationship ... see
http://www.djangoproject.com/documentation/model_api/#many-to-many-relations
hips

class song(meta.Model):
title = ...
duration = ...
instrument = meta.ManyToManyField(instrument)
musician = meta.ManyToManyField(musician)
def __repr__(self):
  return self.title()
class META:
  admin = meta.Admin()

patrick


> 
> Hiya.
> I am not a web developer, okay, just trying to do a band website (so
> take it easy on me, please ;)
> I am having trouble with my models.
> 
> I have the following:
> 
> class musician(meta.Model):
> .......
> class instrument(meta.Model):
> .......
> class song(meta.Model):
> ......
> class songInstrument(meta.Model):
> song = meta.ForeignKey(song, edit_inline=meta.TABULAR, core=True)
> instrument = meta.ForeignKey(instrument)
> musician = meta.ForeignKey(musician)
> def __repr__(self):
>   return "%s, %s, %s" % (self.get_song(), self.get_musician(),
> self.get_instrument())
> class META:
>   admin = meta.Admin()
> 
> So each song has many musicians playing many instruments (ie. Jerry
> might have played drums and bass and read Chaucer in a particular
> song). This is great, and when I add a song in the admin section, I can
> add all this detail, but when I look at songInstrument in admin, there
> are no entries??
> 
> Can anyone tell me:
> a) where have I gone wrong?
> b) is there an easier way to set up these (and similar) models?
> 
> thanks, 
> and keep up to good work, django ist fun
> 

Reply via email to