> Scenario: User A goes to User B's profile. User A know User B,
> so User A adds User B as his friend. He then specifies their
> friendship as "Colleagues".
>
> How can I make this work? I have extended the User-model to
> include a friends-field (ManyToManyField("self")), but I have
> no idea how to specify the friendship type for each of the
> friendships in a dynamic way. Think Facebook. Only one of the
> users specify the friendship type.
It sounds like you want something like a secondary model to which
you can attach such attributes:
class Person(Model):
pass
class FriendshipType(Model):
# "colleague", "roommate", "teacher", etc
pass
class Friendship(Model):
person = Person()
friend = Person()
description = ForeignKey(FriendshipType)
known_since = DateTimeField()
to which you can do things like
my_friends = Friendship.objects.filter(
person=request.User).select_related()
for friendship in my_friends:
do_something('I have known my %s %s since %s' % (
friendship.description,
friendship.friend,
friendship.known_since,
))
in your view.
-tim
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---