How code the relationship like "a person has many friends" code so far.
class Person(models.Model): full_name = models.CharField(maxlength=100) nick_name = models.CharField(maxlength=20) about = models.TextField(blank=True) sex = models.CharField(maxlength=1, choices=SEXES) # contact is also a person object so it is a reference to same person # more study needs to be done on how to add attributes to ManyToMany relationship in Django # e.g. we may need to define whether a contact is my friend etc. # creating a separate class for Contact may not be the a good solution, since a Contact is also a Person contacts = models.ManyToManyField('self') Or like this class PersonRelation(models.Model): person = models.ForeignKey(Person) relations = models.ManyToManyField(Person, related_name = 'friends') type = models.IntegerField(choices=FRIEND_TYPES) group = models.IntegerField(choices=GROUP_TYPES) please highlight pros and cons. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---