Есть модель с такими таблицами:
class Team(models.Model):
title = models.CharField(max_length=100)
country = models.CharField(max_length=100)
points = models.IntegerField(max_length=3, editable=False, null=True, blank=True)
flag = models.ImageField(upload_to='teams', blank=True, null=True)
def __str__(self):
return "%s - %s" % self.country, self.title
class Match(models.Model):
group = models.ForeignKey(Group)
date = models.DateField()
city = models.CharField(max_length=100)
team_a = models.ForeignKey(Team, related_name='team_a')
team_b = models.ForeignKey(Team, related_name='team_b')
total_result = models.CharField(max_length=8)
first_half_result = models.CharField(max_length=8)
def __unicode__(self):
return '%s-%s (%s)' % str(self.team_a), str(self.team_b), str(self.date)