Validate that the input can be converted to a date. Return a Python datetime.date object.
(self, value)
| 487 | } |
| 488 | |
| 489 | def to_python(self, value): |
| 490 | """ |
| 491 | Validate that the input can be converted to a date. Return a Python |
| 492 | datetime.date object. |
| 493 | """ |
| 494 | if value in self.empty_values: |
| 495 | return None |
| 496 | if isinstance(value, datetime.datetime): |
| 497 | return value.date() |
| 498 | if isinstance(value, datetime.date): |
| 499 | return value |
| 500 | return super().to_python(value) |
| 501 | |
| 502 | def strptime(self, value, format): |
| 503 | return datetime.datetime.strptime(value, format).date() |