我的管理员:
from django.core.exceptions import ValidationError
def save_model(self, request, obj, form, change):
if obj.foo == True and obj.bar == '':
raise ValidationError('Please enter the password.')
我的模特是:
foo = models.BooleanField(default=False)
bar = models.CharField(max_length=50, null=True, blank=True)
我想验证当foo
为True时bar
不能为空的模型。但它给了我500. Exception Value: [u'Please enter the password.']