I'm creating an application for foosball matches.
I have models like below:
class Player(models.Model):
match_amount = models.IntegerField(default=0)
wins = models.IntegerField(default=0)
avatar = models.ImageField(blank=True)
user = models.OneToOneField(
on_delete=models.CASCADE,
to=User,
primary_key=True,
related_name='player',
verbose_name=_('user'),
)
def __str__(self):
return self.user.get_full_name()
class Team(models.Model):
players = models.ManyToManyField(Player)
wins = models.IntegerField(default=0)
def __str__(self):
return "Team %s" % self.pk
class Match(models.Model):
date = models.DateField(default=now)
def __str__(self):
return "Match on %s" % self.date
class TeamMatch(models.Model):
team = models.ForeignKey(Team)
match = models.ForeignKey(Match)
points = models.IntegerField()
def __str__(self):
return "Match %s" % self.team
Is these models are well created?
Thanks much for each tip and corrections.