class Match(models.Model):
date = models.DateField('my date')
time = models.TimeField()
duration = models.DurationField(null = True)
category = models.CharField(max_length=20, choices=CATEGORY_CHOICES, default=CATEGORY_CHOICES[0][0])
place = models.CharField(max_length=256, null=True)
game_status = models.CharField(max_length=256, null=True) #completed or not
# Foreign Keys
event = models.ForeignKey(Event, on_delete=models.CASCADE)
# teams = models.ManyToManyField(Team)
class Meta:
abstract = True
class Swimming(Match):
time = models.TimeField(null=True)
player = models.ManyToManyField(Player, related_name='player_swimming')
game_level = models.CharField(max_length=256, null=True, choices=LEVEL_CHOICES) # like semi-final, final etc
game_specific = models.CharField(max_length=256,null=True, choices=EVENT_CHOICES) #like Men's Shot Put or Men's Triple Jump etc
def __str__(self):
return str(self.game_level)
Это моя начальная модель Плавание , которое расширено от базового класса Матч . Теперь я хочу добавить одну промежуточную модель PlayerSwimming к Плавание модель. Теперь она застревает на этапе makemigration. Я перепробовал все возможности, такие как сначала удаление миграции и добавление снова, комментирование и миграция, а затем раскомментирование и миграция снова. Помоги мне! Новая модель:
class Swimming(Match):
player = models.ManyToManyField(Player, through='PlayerSwimming')
game_level = models.CharField(max_length=256, null=True, choices=LEVEL_CHOICES) # like semi-final, final etc
game_specific = models.CharField(max_length=256,null=True, choices=EVENT_CHOICES) #like Men's Shot Put or Men's Triple Jump etc
def __str__(self):
return str(str(self.category) + " " + str(self.date))
class PlayerSwimming(models.Model):
player = models.ForeignKey(Player, on_delete=models.CASCADE)
swimming = models.ForeignKey(Swimming, on_delete=models.CASCADE, default='')
time = models.IntegerField(default=-1)
medal = models.CharField(max_length=256,blank=True, choices=MEDAL_CHOICES)
def __str__(self):
return str(self.player)
# return str(self.swimming) + str(" ") + str(self.player)
class Meta:
ordering = ['time']