Django Baseball Site Model

53 views
Skip to first unread message

David Gomez

unread,
Jan 16, 2013, 6:59:24 PM1/16/13
to django...@googlegroups.com
Hi, I would like to make a website about baseball player from an specific country, but I'm stock how to make the model for the player stat. 

My Current a sample model is like this (The Stat Class is going to be much longer):

class PLayer_Bios(models.Model):
  my_id               = models.SlugField(unique=True)
  mlb_id           = models.CharField(max_length=50)    
  name             = models.CharField(max_length=50) 
  last             = models.CharField(max_length=50)
  middle           = models.CharField(max_length=50, blank=True)
  jersey           = models.CharField(max_length=5)
  weight           = models.CharField(max_length=10)
  height           = models.CharField(max_length=10)
  bod              = models.CharField(max_length=50)
  birth_city       = models.CharField(max_length=50)
  birth_country    = models.CharField(max_length=50)
  pro_debut_date   = models.CharField(max_length=50)
  primary_position = models.CharField(max_length=50)
  team_name        = models.CharField(max_length=50)
  throws           = models.CharField(max_length=50)
  bats             = models.CharField(max_length=50)

 
  def __unicode__(self):
    return self.name

class Stat (models.Model):
    player_id     = models.ForeignKey('PLayer_Bios')
    stat_id        = models.CharField(max_length=50, unique=True)
    year            = models.IntegerField(max_length=50)
    h                = models.IntegerField(max_length=50)
    2h              = models.IntegerField(max_length=50)
    


    def __unicode__(self):
        return self.stat_id
Here is how I want the template to look like:
Each PLayer have this stat and if you see the year, the stat can have repeat year in two different row if the player was move to another team. Thanks in advance
BATTING Regular Season Career Stats
YEARTEAMLGLEVELGABRHTB2B3BHRRBIBBIBBSOSBCSAVGOBPSLGOPSGO/AO
1992[+]  Minors582102344661004292605223.210.311.314.626-
1993GBOSALA (Full)12851585152203141157158195189.295.376.394.770-
1994[+]  Minors138540103186250271156858361508.344.410.463.873-
1995COLINTAAA12348696154205279245611562012.317.394.422.816-
1995NYYALMLB1548512184107301100.250.294.375.669-
1996NYYALMLB1575821041832502561078481102147.314.370.430.800-

Mac

unread,
Jan 17, 2013, 12:34:23 AM1/17/13
to django...@googlegroups.com
You could create another field under Stat called team, and rename the class stat to "Stint" or "Term" or "Session" ( I can't think of a better word ) to represent the stats of the player's "stint" at that team, that year.

You may also want to and another field to represent how many times the player was traded that season, and in what order, most likely using an integer field.

Ex:

class Stint(models.Model):
    # some stuff here
    team = models.CharField()
    year = models.IntegerField()
    traded = models.IntegerField()     #if 0, then he wasn't traded, if 1 this is his 2nd team, etc...

Hope this helps,
Mac

David Gomez

unread,
Jan 24, 2013, 10:15:22 AM1/24/13
to django...@googlegroups.com
What about my model? Is this model good for what I'm planning to do?
Reply all
Reply to author
Forward
0 new messages