我已经看到很多关于此错误的帖子,但没有与"添加"。当我点击"添加部分属性"在管理界面中。
通过评论:
notAllowedCoursePair = models.ManyToManyField(Course, blank=True)
从我的SectionAttributes模型我已经确定这条线导致了这个问题。删除blank = True无济于事。当我删除整行时,添加工作正常。但是,它对我来说看起来很无害。和我的其他一些ManyToManyFields一样。关于"课程"是否有一些特别的东西?表链接到?
class Course(models.Model):
bb_course_id = models.IntegerField(default=0)
name = models.CharField(max_length=100)
grade_level = models.IntegerField(default=0)
department = models.ForeignKey(Department, blank=True, null=True)
def __str__(self):
return self.name
class SectionAttributes(models.Model):
num_required_courses = models.IntegerField(default=0)
num_drop_downs = models.IntegerField(default=1)
grade = models.ManyToManyField(Grade)
section = models.ManyToManyField(Section)
term = models.ManyToManyField(Term)
instructions = models.TextField(blank=True, null=True)
checkboxes = models.ManyToManyField(Checkbox, blank=True)
notAllowedCoursePair = models.ManyToManyField(Course, blank=True)
on_change_popup = models.CharField(max_length=50, null=True, blank=True)
student_num_requested = models.BooleanField()
def __str__(self):
return str(self.section.all()) + " " + str(self.term.all()) + " " + str(self.grade.all())