Fix bug in date parsing

This commit is contained in:
Itai Shirav 2016-06-30 16:12:02 +03:00
parent 9489115d6e
commit 4efdcda97b

View File

@ -73,7 +73,8 @@ class DateField(Field):
if isinstance(value, int): if isinstance(value, int):
return DateField.class_default + datetime.timedelta(days=value) return DateField.class_default + datetime.timedelta(days=value)
if isinstance(value, basestring): if isinstance(value, basestring):
# TODO parse '0000-00-00' if value == '0000-00-00':
return DateField.min_value
return datetime.datetime.strptime(value, '%Y-%m-%d').date() return datetime.datetime.strptime(value, '%Y-%m-%d').date()
raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value)) raise ValueError('Invalid value for %s - %r' % (self.__class__.__name__, value))