If the Friend is really a user...wouldn't something like this work: class Friends(models.Model): parent_user = models.ForeignKey(User, related_name="user") friend_user = models.ForeignKey(User,related_name="friends")
Then for the parent_user's friends...you'd do something like: parent_users_friends = parentuser.friends_set.all() to bring back a listing of all of his friends. On Jul 27, 8:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > i'm working on an app that has a table called friends whose model > looks like this: > > class Friend(models.Model): > user = models.ForeignKey(User) > friend = models.CharField(maxlength=100) > status = models.CharField(maxlength=1,choices=FSTATUS_CHOICES) > > def __str__(self): > return self.friend > > user is the user that added the friend, while friend SHOULD be the id > of the user that has been added. Both fields use the user table. I > cant use the same foreign key for both, this would be an error. > Ideally i would want a drop down box with all the username for the > friend field. I thought about using choices, but cant seem to create > a tuple that is dynamically populated from the username field in the > user table. > > Any ideas how i could go about this? > > P.S is this a recursive relationship? i dont think so but hopefully > some DB guru can shed some light. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---