Hi, > I have a pretty large site that tracks a football team and it's league > ( http://www.muskegohitmen.com ).
That sounds interesting.. ;-) > Things you'll probably want to consider > Seasons - a very small model class, but organizing things by a season > becomes pretty tricky with out this. > Rosters ( players per season ) > Staff ( staff Per season ) > Game category ie, pre-season, regular, playoff, championship. > * keeping track of win/losses and ties for each game type. > > However, my set up track only 1 team which defined by a simply boolean > check, and can be changed at any time. I have a thin layer that keeps > track of win/losses in the league, but not the stats of the whole > league. I have a separate league manager application which handles > things on a league wide level. > So this may not fit your purpose exactly. Thx for your input! I have to track several teams in several leagues, so it's quite tricky. > I have a trac site set up. If you are are interested in looking over > the source shoot me an email esatterwhite -[at]- wi.rr.com. I'll set > you up with a password. That would be great, I'll write you a e-mail. Maybe I can use some parts or get some ideas out of your work! Chris > On Oct 7, 4:16 pm, Curt <curt.merr...@gmail.com> wrote: >> Instead of including every player in the Game model, I would add a >> field to the Player model to assign which team a player belongs to: >> >> 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) >> team = models.ForeignKey(Team) >> >> Now you can just specify the home_team and the away_team in the Game >> model without having to add every player. >> >> For more functionality (like allowing players to switch teams) you >> could use a through table that includes Player, Team, join_date and >> leave_date -- The example in the docs is a good starting point for >> that:http://docs.djangoproject.com/en/dev/topics/db/models/ >> >> I'm not sure how to answer a), but you can figure out b) because the >> goal_scorer will be assigned to either home_players or away_players in >> your original Game model, or the goal_scorer will be assigned to the >> home_team or away_team in the modified models. >> >> On Oct 5, 7:21 am, "c!w" <wittwe...@gmail.com> wrote: >> >> >> >> > 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 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 -~----------~----~----~----~------~----~------~--~---