It looks you're setting a many-to-many reflexive (circular) relationship
between users.   It seems it would be better to add a ManyToManyField on the
User model, eg:

class User(models.Model):
    ...
    friends = ManyToManyField(User)


Then you could just use "user.friends"



On Thu, Sep 3, 2009 at 9:50 AM, Yanik <yanikpro...@gmail.com> wrote:

>
> Let's say I have a model "Friends" that looks something like:
>
> class Friend(models.Model):
>        user = models.ForeignKey(User)
>        friend = models.ForeignKey(User, related_name="friend")
>
> I want a list of "User" instances of a user's friends. Is my only
> option to:
>
> 1) Get list of "Friends"
> 2) Then get list of "Users" where id in friends.value_llist('id')
>
> Or is there a way to do a query on the "Friend" model and as to return
> "User" instances of friends?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to