如何将数据添加到ManyToMany字段?
我在任何地方都找不到它,所以您的帮助对我非常有用:)这是该字段: categories = models.ManyToManyField(fragmentCategory) FragmentCategory: class fragmentCategory(models.Model): CATEGORY_CHOICES = ( ('val1', 'value1'), ('val2', 'value2'), ('val3', 'value3'), ) name = models.CharField(max_length=20, choices=CATEGORY_CHOICES) 这是发送的表格: <input type="checkbox" name="val1" /> <input type="checkbox" name="val2" /> <input type="checkbox" name="val3" /> 我尝试过这样的事情: categories = fragmentCategory.objects.get(id=1), 要么: categories = [1,2]