Thursday, January 24, 2013

Re: Django Baseball Site Model

What about my model? Is this model good for what I'm planning to do?

On Thursday, January 17, 2013 12:34:23 AM UTC-5, Mac wrote:
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


On Wednesday, January 16, 2013 3:59:24 PM UTC-8, David Gomez wrote:
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-

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/g9we0yl7DVoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment