The idea is that there are two models: Group and Player. My objective is that there are different Groups and each group has players. Each player can belong to one or more groups. Inside a group, each player has some points accumulated, but the same player can have different points accumulated in another group.
class Player(models.Model):
username = models.CharField(max_length = 200)
won_games = models.IntegerField(default=0)
class Point(models.Model):
player = models.ForeignKey(Player, on_delete=models.PROTECT, related_name='points')
val = models.IntegerField()
group = models.ForeignKey(Group, on_delete=models.PROTECT, related_name='points')
class Group(models.Model):
id = models.CharField(max_length = 200)
players = models.ManyToManyField(Player,related_name="groups")
points = models.ManyToManyField(Point)
I am confused because I don't know how to make that a player has "x" points in group A (for example) and also has "y" points in group B. I want to be able to show the data of a group, for each group, show its members and their points.