Hi there, I'm not sure if the is the best place to ask, but I have some questions about how to best define my model in Django. I'm still fairly new to Python and really new to Django, so if you see that I've done something stupid, feel free to correct me.
I'm trying to build a simple (American) football pool app. I've included my current model at the end of my post. It is currently VERY simple, as I was just messing around getting a feel for Django. The questions I have mostly relate to the relations between games, game results, teams. 1) What is the "best" way to define the relationship between one Game and the two Teams that are playing the game? 2) When I use the admin interface to create a new "Game Result", it displays two drop-downs for selecting teams. It currently lists all the teams in the DB. Is there a way to restrict the items in the drop-down to only include the two teams that played in that specific game? 3) When creating a new Game via the admin interface, the drop-downs for the two teams are both labeled "Team". Is there a way to change the labels to "Home Team" and "Away Team"? Thanks for any advice you can give! Nate -- from django.core import meta # Create your models here. class User(meta.Model): fields = ( meta.CharField('username', maxlength=20), meta.CharField('password', maxlength=10), ) admin = meta.Admin() def __repr__(self): return self.username class Team(meta.Model): fields = ( meta.CharField('name', maxlength=25), meta.CharField('city', maxlength=25), ) admin = meta.Admin() def __repr__(self): return self.city + " " + self.name class Game(meta.Model): fields = ( meta.DateTimeField('date'), meta.ForeignKey(Team, name="home_team_id", rel_name="home_team", related_name="home_team"), meta.ForeignKey(Team, name="away_team_id", rel_name="away_team", related_name="away_team"), ) admin = meta.Admin() def __repr__(self): return self.get_away_team().name + " at " + self.get_home_team().name + " ("+self.date.strftime('%m/%d/%Y @ %H:%M') + ")" class GameResult(meta.Model): fields = ( meta.OneToOneField(Game), meta.IntegerField('winning_score',blank=True), meta.IntegerField('losing_score',blank=True), meta.ForeignKey(Team, name="winning_team_id", rel_name="winning_team", related_name="winning_team"), meta.ForeignKey(Team, name="losing_team_id", rel_name="losing_team", related_name="losing_team"), ) admin = meta.Admin() def __repr__(self): return `self.winning_team_id` + " (" + `self.winning_score` + ")/" + `self.losing_team_id` + " (" + `self.losing_score` + ")" class Pick(meta.Model): fields = ( meta.ForeignKey(User), meta.ForeignKey(Game), meta.ForeignKey(Team, rel_name='winner'), meta.IntegerField('points') ) admin = meta.Admin() def __repr__(self): return "Picks for: " + self.get_user().username