我有一个问题。我想删除'通过'模型,同时在Django Admin中编辑竞争模型。它是关于编辑m2m字段' competition_field'。示例:与字段竞争('高度','宽度),我将删除' width'从m2m开始,模型中没有任何变化,FieldValues'我已经尝试过我所知道的一切,但没有取得任何成功。
这是我的 models.py
class Fields(models.Model):
field_name = models.CharField(max_length=100, unique=True)
class Competitions(models.Model):
competition_title = models.CharField(max_length=100, unique=True)
competition_field = models.ManyToManyField(Fields)
class Applications(models.Model):
application_applicant = models.ForeignKey(Applicant, on_delete=models.CASCADE)
application_competition = models.ForeignKey(Competitions, on_delete=models.CASCADE,)
application_value = models.ManyToManyField(Fields, through='FieldsValues')
class FieldsValues(models.Model):
catch_fields = models.ForeignKey(Fields, on_delete=models.CASCADE)
application = models.ForeignKey(Applications, on_delete=models.CASCADE)
value = models.TextField(null=True, default=0)