On Wed, Dec 2, 2009 at 2:04 PM, Jeffrey Taggarty <jtagga...@gmail.com>wrote:

> Hi,
> I am having difficulties with listing this type of data. Scenario is
> as follows:
>
> 1) user1 add's a friend called user2
> 2) user2 confirms that user1 is his friend
>
> what should happen is user2 and user1 see's each others name in their
> friends list. What's happening now is I am able to add user2 to user1
> friends list but user1 cannot see user2 in his/her list. My question
> is how do I get user1 to show up in user2's list and user2 to show up
> in user1's friend list if a user has confirmed friendship? I was
> thinking of utilizing the confirmation status in the model and because
> that user1 and user2's id is both in the confirmed relationship I
> don't see any integrity issues here. Any tips?


You haven't done anything to express the reverse relationship, if I
understand all this correctly, so of course it doesn't show up.  A
straightforward way to solve that would be to simply add the reverse entry
at the same time you add the initial entry, since you are assuming the
friendship is bidirectional.  In other words, at some point when you save a
form, you're creating a row like this:

rel = Friendship.objects.create(to_friend=user1, from_friend=user2)
rel.save()

But are you doing the reverse?

rel = Friendship.objects.create(to_friend=user2, from_friend=user1)
rel.save()

There are other ways to accomplish it, but I think this is the simplest.

Nick

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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