I am trying to develop a scoring sheet app for my football club.
I have models for Player, Scoresheet, Season ,etc.
What I would like to achieve is basically when a game takes place, the scoresheet model will have a form where the person can capture the total score of the team and also the goals of each player, freekicks.
My issue is how do I link the players stats to the scoresheet in a form, for example if I have 11 players, I want the scoresheet to be able to take in the 11 players and how many goals they scores, freekicks if any, red cards if any etc.
I am aware that something is missing I am not sure what it is please help. my Models are as follows
class Player(models.Model):
user = models.OneToOneField(User,on_delete=models.SET_NULL,null=True,related_name="playeruser")
Player_name = models.CharField(max_length=40)
Player_surname = models.CharField(max_length=40)
Player_ID = models.CharField(max_length=40)
Player_Email = models.CharField(max_length=40)
Player_Contact = models.CharField(max_length=40)
category = models.ForeignKey(Category,on_delete=models.CASCADE,related_name="pcategory")
Player_preferred = models.CharField(choices=Roles,default="default",max_length=16)
def __str__(self):
return self.Player_name + " " + self.Player_surname
class Score_sheet(models.Model):
season = models.ForeignKey(Season,on_delete=models.CASCADE,related_name="season")
category = models.ForeignKey(Category,on_delete=models.CASCADE,related_name="sscategory")
players = models.ManyToManyField(Player,related_name="players")
captain = models.ForeignKey(Player,on_delete=models.CASCADE,related_name="captain")
Date = models.DateField()
Venue= models.CharField(max_length=40,null=True,blank=True)
description = models.TextField(null=True,blank=True)
goals= models.IntegerField(null=True,blank=True)
freekicks = models.IntegerField(null=True,blank=True)
redcards = models.IntegerField(null=True,blank=True)
yellowcards = models.IntegerField(null=True,blank=True)
def __str__(self):
return str(self.season) + " " + self.Venue
Please let me know if anything is unclear.