Moved BooleanField 'required' validation in validate()

This commit is contained in:
Claude Paroz 2013-01-26 16:39:20 +01:00
parent 55416e235d
commit d18893d5ce
1 changed files with 3 additions and 2 deletions

View File

@ -665,10 +665,11 @@ class BooleanField(Field):
value = False
else:
value = bool(value)
value = super(BooleanField, self).to_python(value)
return super(BooleanField, self).to_python(value)
def validate(self, value):
if not value and self.required:
raise ValidationError(self.error_messages['required'])
return value
def _has_changed(self, initial, data):
# Sometimes data or initial could be None or '' which should be the