我的模型中有OnetoOnefield,设置为null = True且空白= True。一切都运行正常,但一旦我尝试从管理站点保存该模型的对象,我得到IntegrityError,说该字段不能为空。
我的模特是:
class Appointment(models.Model):
doctor = models.OneToOneField(Doctor)
clinic = models.OneToOneField(Clinic, null=True, blank=True)
hospital = models.OneToOneField(Hospital, null=True, blank=True)
答案 0 :(得分:0)
看看这个领域。
doctor = models.OneToOneField(Doctor)
class Appointment(models.Model):
doctor = models.OneToOneField(Doctor)
clinic = models.OneToOneField(Clinic, null=True, blank=True)
hospital = models.OneToOneField(Hospital, null=True, blank=True)