On Sat, 2007-04-28 at 23:27 +0000, Henrik Lied wrote:
> Thank you for your example, Tim.
> I'm sorry, but the problem with it is that it isn't symmetrical.
> 
> A part of my Profile-model looks like this:
> class Profile(models.Model):
>     user = models.ForeignKey(User)
>     friends = models.ManyToManyField("self")
> 
> This makes it very easy to create and maintain a relationship
> between users - but I have no idea how to specify the friendship
> type. Is it even possible?

Go back and have another look at Tim's suggestion. It is the right
approach. The problem isn't that the relationship is symmetrical, you're
right: the problem is that you cannot attach any extra attributes to the
relationship table (the table that connects the two ends) using
ManyToManyField.

Instead of trying to make the relationship a direct Many-to-Many, which
does not let you put any fields on the intermediate table, you need to
construct the intermediate table yourself via a couple of joins.

See, also
http://www.djangoproject.com/documentation/models/m2m_intermediary/ for
a similar example.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to