try date formats
This commit is contained in:
parent
1d6d53e282
commit
f591f66634
1 changed files with 10 additions and 3 deletions
|
@ -1032,9 +1032,16 @@ class Item(models.Model):
|
||||||
elif sort_type == 'date':
|
elif sort_type == 'date':
|
||||||
value = self.get(source)
|
value = self.get(source)
|
||||||
if isinstance(value, string_types):
|
if isinstance(value, string_types):
|
||||||
value = datetime_safe.datetime.strptime(value, '%Y-%m-%d')
|
value_ = None
|
||||||
set_value(s, name, value)
|
for fmt in ('%Y-%m-%d', '%Y-%m', '%Y'):
|
||||||
|
try:
|
||||||
|
value_ = datetime_safe.datetime.strptime(value, fmt)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
if value_ is not None:
|
||||||
|
set_value(s, name, value_)
|
||||||
s.save()
|
s.save()
|
||||||
|
|
||||||
def update_facet(self, key):
|
def update_facet(self, key):
|
||||||
|
|
Loading…
Reference in a new issue