Patched DateField and DateTimeField to check for None values before trying to perform date(time) conversion.

Signed-off-by: Kevin Stone <kevinastone@gmail.com>
This commit is contained in:
Kevin Stone 2013-03-06 15:16:37 -08:00
parent 6bea275de8
commit 2f8d8b499e

View File

@ -534,6 +534,8 @@ class DateField(WritableField):
raise ValidationError(msg)
def to_native(self, value):
if value is None:
return None
if isinstance(value, datetime.datetime):
value = value.date()
if self.format.lower() == ISO_8601:
@ -599,6 +601,8 @@ class DateTimeField(WritableField):
raise ValidationError(msg)
def to_native(self, value):
if value is None:
return None
if self.format.lower() == ISO_8601:
return value.isoformat()
return value.strftime(self.format)