【发布时间】:2017-06-06 22:45:18
【问题描述】:
我在 pre_save 中提出了一个validationError,但是每当我尝试创建一个新对象时,我并没有像其他对象那样得到红色错误,而是得到一个带有错误的黄页。
@receiver(pre_save, sender=Student)
def student_pre_save(sender,instance, **kwargs):
if instance.classroom.student_set.count() == instance.classroom.QttMax_Stu:
raise ValidationError("No places left")
【问题讨论】:
标签: python django django-models django-admin