Форум сайта python.su
Есть модели Player и Match, связанные many_to_many
class Player(models.Model): number = models.IntegerField(u'Номер', blank=True, null=True) last_name = models.CharField(u'Фамилия', max_length=100) name = models.CharField(u'Имя', max_length=100) class Match(models.Model): tournament = models.ForeignKey(Tournament, verbose_name=u'Турнир', on_delete=models.CASCADE) tour = models.ForeignKey(Tour, verbose_name=u'Тур', on_delete=models.CASCADE) structure_home = models.ManyToManyField( Player, verbose_name=u'Состав команды хозяев', related_name='home_players', blank=True) class Statistics(models.Model): player = models.ForeignKey(Player, verbose_name=u'Игрок', on_delete=models.CASCADE) tournament = models.ForeignKey('tournaments.Tournament', verbose_name=u'Турнир', on_delete=models.CASCADE) ... games = models.IntegerField(u'Игры', default=0) ...
Отредактировано tol_drew (Авг. 28, 2018 05:46:24)
Офлайн