phloopy wrote:

>I'm building a system that manages sports leagues, hockey is the first
>one I'm worried about but I intend it to be flexible enough for others
>as well.  There are three objects that are involved in this question:

>Person: represents anybody involved in the league, has many roles
>(that is, Person's role = models.ManyToManyField(Roles))

>Role: Any given person can be a number of roles in the app. [...]

>Game: A game is many-to-many with Person (Game's people =
>models.ManyToManyField(Person)), but for any given person related to
>the game it must be specified what their role is for that game.  They
>cannot be both a player and a ref, for example.

>If I weren't using django models I'd create a intermediary triple join
>table, with fields for player, role, and game.  I can't conceive how
>to do such a thing with Django though, since the intermediary join
>tables are done behind the scenes with ManyToMany relationships and
>seem to support two way relationships only.

You can use an explicit intermediary join model:

class GameParticipant(models.Model):
        game = models.ForeignKey(Game)
        person = models.ForeignKey(Person)
        role = models.ForeignKey(Role)

        class Meta:
                unique_together = [('game', 'person')]


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to