On Fri, 2006-08-11 at 22:02 -0700, Bryan Murdock wrote: > First I must admit that I'm a databse dummy. I'm using fairly recent > django code from svn. I have a simple desire. I want people who can > be organized into committees, with each committee having a committee > leader, also a person. I wrote up my models like so: > > class Person( models.Model ): > firstname = models.CharField( maxlength=200 ) > lastname = models.CharField( maxlength=200 ) > email = models.EmailField() > phone_number = models.PhoneNumberField() > committee = models.ForeignKey( 'Committee' )
You shouldn't use the string argument (I mean, I never do that). And what if one person is in two committees? > notes = models.TextField() > > def __str__( self ): > return self.firstname + " " + self.lastname > > class Admin: > pass > > class Committee( models.Model ): > name = models.CharField( maxlength=200 ) > leader = models.ForeignKey( Person, > related_name = 'commitee_leading' ) > notes = models.TextField() Use the ManyToManyField here. members = models.ManyToManyField(Person, related_name = 'member_of') -- Maciej Bliziński http://automatthias.wordpress.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---