The way I was thinking of doing it was to have two foreignkeys named friend1 and friend2 then when you do your list you could run (something like)
friends = Friendship.objects.get(friend1__exact=user) and friends2 = Friendship.objects.get(friend2__exact=user) Then you have a complete instance of the friends. I'm not by a django computer right now to figure it out but friends and friends2 could be added together to pass one variable. On Dec 22, 10:10 am, kev <[email protected]> wrote: > Hello, > Im reading a django book and it adds friends to user authentication > system by making: > > (was .96) > > class Friendship(models.Model): > from_friend = models.ForeignKey( > User, related_name='friend_set' > ) > to_friend = models.ForeignKey( > User, related_name='to_friend_set' > ) > def __str__(self): > return '%s, %s' % ( > self.from_friend.username, > self.to_friend.username > ) > class Admin: > pass > class Meta: > unique_together = (('to_friend', 'from_friend'), ) > > But for this to work, you have to add friendship both ways. Ex/ user1 -> > user2 and user2 -> user1 which means almost duplicate entries in > > this model. And anytime you modify one friendship, you have to do the > same to the other one. > > Is there a better way to do this so that only one entry exists in the > db? Any suggestions are welcome! > > Kevin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

