Hi,

I'm working with Django since a few weeks and I really *love* it!

I came across a problem I didn't find any help so I thought it might
be a good idea to ask the pros.

I need to model persons and each person should have a list of other
persons (a 'collaborates-with'-property).

I have to save some meta-data about the connection, so I need a
intermediary table (let's call it "PersonCollaboration").

In normal SQL I would do it with a simple join table: person1_id |
person2_id | meta-stuff...

I'm not sure how to handle this in django.

How would you do that?

I read http://heather.koyuk.net/refractions/?p=151  - is this the only
way to go?

What about a symmetric approach?

Here is what I got so far (inspired from 
http://heather.koyuk.net/refractions/?p=151):

class PersonCollaboration (models.Model):
      person1 = models.ManyToManyField('Person',
related_name='person1')
      person2 = models.ManyToManyField('Person',
related_name='person2)
      ...

class Person (models.Model):
       name = models.CharField(max_length=250, unique=True)
       collaborates_with = models.ManyToManyField('self',
through='AuthorCollaboration', symmetrical=False

This is not symmetric - I could try to create two PersonCollaboration-
objects, but this is not really clean...

Thanks a lot for your support,

chris

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