Skip to content

Instantly share code, notes, and snippets.

@debuggerpk
Created January 28, 2012 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save debuggerpk/1694025 to your computer and use it in GitHub Desktop.
Save debuggerpk/1694025 to your computer and use it in GitHub Desktop.
models.py
from django.db import models
# Create your models here.
class Leagues(models.Model):
LeagueName = models.CharField(max_length=200)
def __unicode__(self):
return self.LeagueName
class Team(models.Model):
TeamLeague = models.ForeignKey(Leagues)
TeamName = models.CharField(max_length=200)
def __unicode__(self):
return self.TeamName
class LeagueTable(models.Model):
league = models.ForeignKey(Leagues)
team = models.ForeignKey(Team)
matches_played = models.IntegerField()
matches_won = models.IntegerField()
matches_drawn = models.IntegerField()
matches_lost = models.IntegerField()
points = models.IntegerField()
class FixtureTable(models.Model):
league = models.ForeignKey(Leagues)
fixture_date = models.DateField('Fixture Date')
team_one = models.ForeignKey(Team, related_name="home_set")
team_one_score = models.IntegerField()
team_two = models.ForeignKey(Team, related_name="away_set")
team_two_score = models.IntegerField()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment