Boolean field type.
| 502 | |
| 503 | |
| 504 | class BooleanField(BaseField): |
| 505 | """Boolean field type.""" |
| 506 | |
| 507 | def to_python(self, value): |
| 508 | try: |
| 509 | value = bool(value) |
| 510 | except (ValueError, TypeError): |
| 511 | pass |
| 512 | return value |
| 513 | |
| 514 | def validate(self, value): |
| 515 | if not isinstance(value, bool): |
| 516 | self.error("BooleanField only accepts boolean values") |
| 517 | |
| 518 | |
| 519 | class DateTimeField(BaseField): |