Return a Python boolean object.
(self, value)
| 806 | widget = CheckboxInput |
| 807 | |
| 808 | def to_python(self, value): |
| 809 | """Return a Python boolean object.""" |
| 810 | # Explicitly check for the string 'False', which is what a hidden field |
| 811 | # will submit for False. Also check for '0', since this is what |
| 812 | # RadioSelect will provide. Because bool("True") == bool('1') == True, |
| 813 | # we don't need to handle that explicitly. |
| 814 | if isinstance(value, str) and value.lower() in ("false", "0"): |
| 815 | value = False |
| 816 | else: |
| 817 | value = bool(value) |
| 818 | return super().to_python(value) |
| 819 | |
| 820 | def validate(self, value): |
| 821 | if not value and self.required: |