Long time lurker, first time poster . . . (I would have asked more questions before, but the answers have always been in the archives.)
I'm working on an app to show the rapidly approaching NCAA tournament brackets, and am having some trouble with it. Since I'm quite new to Django I thought I'd find out if my approach is the right way to go before I invest any mroe time in it. My model has two objects: Teams and Games: Teams is pretty straight forward, with fields for name, region and seed, among other elements that are pretty flat. The games model is somewhat more complicated with fields for a gameID, round, region, a winner, the seed x2 (if it's in the first round), Previous Game x2 (if it's after the first round), and two teams. I'm trying to use a manager to pull the teams in from the winners of the previous games(or from the seeds/regions if it's the first round). Does this sound like a good way to do it? I'm including the model code (please don't laugh). The commented out parts are where I've been having some trouble with the managers. Any tips and suggestions would be greatly appreciated. oh, and I'm running 0.95.1 from django.db import models # Create your models here. REGION_CHOICES = ( ('1', 'Region in Upper Left'), ('2', 'Region in Lower Left'), ('3', 'Region in Upper Right'), ('4', 'Region in Lower Right'), ('5', 'Final Four'), ) ROUND_CHOICES = ( ('1', 'First Round'), ('2', 'Second Round'), ('3', 'Regionals'), ('4', 'Elite Eight'), ('5', 'Final Four'), ('6', 'Championship'), ) #class Game1Manager(models.Manager): # if Games.round == 1: ### get the teams from the seed ### Select team from seed and region # def get_query_set(self): # return teams.objects.filter(region==self.objects.region).filter(seed==self.objects.seed_1) # else: # ### get the teams from the previous winners # #if no winner, return nothing # ### Select team from the region and previous winner # def get_query_set(self): # return self.objects.filter(gameID==previous_1).winner class Team(models.Model): name = models.CharField(maxlength=20) region = models.IntegerField(choices=REGION_CHOICES) seed = models.IntegerField(null = True) class Admin: pass list_filter = ('region', ) list_display = ('name', 'region', 'seed') class Meta: ordering = ['seed'] def __str__(self): return self.name class Game(models.Model): gameID = models.IntegerField(unique=True) round = models.SmallIntegerField(choices=ROUND_CHOICES) region = models.IntegerField(choices=REGION_CHOICES) seed_1 = models.IntegerField(null=True) seed_2 = models.IntegerField(null=True) # team_1 = Game1Manager() # team_2 = Game2Manager() WINNER_CHOICES = ( ('1','team1'), ('2','team2'), ) winner = models.IntegerField(blank=True, choices=WINNER_CHOICES) previous_1 = models.IntegerField(null=True) previous_2 = models.IntegerField(null=True) class Admin: fields = ( ('Game', {'fields': ('round','region','gameID',)}), ('Winner', {'fields': ('winner',)}), ('First round only', {'fields': ('seed_1','seed_2',)}), ('Relationship', {'fields':('previous_1','previous_2',)}), ) list_filter = ('round', 'region',) list_display = ('round', 'winner', 'region', 'gameID', 'seed_1', 'seed_2',) class Meta: unique_together = (("round", "gameID"),) def __str__(self): return '%s %s vs %s' % (self.team1, self.team2, self.round) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---