Hi,
I trying to create a hockey database, based on Django.
The heaviest part so long is to define the structure of my models.
There I need some help.
What I have so far..
class Team(models.Model):
name = models.CharField(max_length=60)
class Player(models.Model):
surname = models.CharField(max_length=60)
lastname = models.CharField(max_length=60)
class Game(models.Model):
date_time = models.DateTimeField()
home_team = models.ForeignKey(Team,related_name='home_team')
away_team = models.ForeignKey(Team,related_name='away_team')
home_players = models.ManyToManyField(Player,blank=True)
away_players = models.ManyToManyField(Player,blank=True)
class GameGoal(models.Model):
goal_scorer = models.ForeignKey(Player,blank=True,null=True)
first_assist = models.ForeignKey(Player,blank=True,null=True)
game = models.ForeignKey(Game)
So now I have the following problems with these models.
a) How can I limit the choice (in the admin page) of goal_scorer to
Players, which are assigned to the Game?
b) A GameGoal should be connected to the home_team or the away_team,
how can I handle this? Add a foreignkey to Team and limit the choice
to the both teams?
c) Is there a better way, to define such a case?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---