Commit 2f8d8b49 by Kevin Stone

Patched DateField and DateTimeField to check for None values before trying to…

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

Signed-off-by: Kevin Stone <kevinastone@gmail.com>
parent 6bea275d
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment