I have the following models in Django:
from django.db import models
class Team(models.Model):
name = models.CharField(max_length=200)
class Match(models.Model):
team_home = models.ForeignKey(Team)
team_visitors = models.ForeignKey(Team)
league = models.CharField(max_length=200)
date_played = models.DateField()
The idea is to be able to have a 'Match' object which has two teams who played a match of some game. It would be very odd that a team be playing itself. How can I guarantee that team_home
is not equal to team_visitors
?