mirror of https://github.com/django/django.git
Moved BooleanField 'required' validation in validate()
This commit is contained in:
parent
55416e235d
commit
d18893d5ce
|
@ -665,10 +665,11 @@ class BooleanField(Field):
|
||||||
value = False
|
value = False
|
||||||
else:
|
else:
|
||||||
value = bool(value)
|
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:
|
if not value and self.required:
|
||||||
raise ValidationError(self.error_messages['required'])
|
raise ValidationError(self.error_messages['required'])
|
||||||
return value
|
|
||||||
|
|
||||||
def _has_changed(self, initial, data):
|
def _has_changed(self, initial, data):
|
||||||
# Sometimes data or initial could be None or '' which should be the
|
# Sometimes data or initial could be None or '' which should be the
|
||||||
|
|
Loading…
Reference in New Issue