def to_python(self, value): try: return date(*(int(_) for _ in value.split('-'))) except ValueError: raise ValidationError('invalid date format')