# HG changeset patch
# User Daniel Cuenca <daniel@akoha.org>
# Date 1207172270 14400
# Node ID 3645c413c464193ea0abde1687d882befd965ed2
# Parent 18041c06e124891c79d5732657a07b591c009d74
SelectDateWidget can now parse datetime objects.
diff --git a/django/newforms/extras/widgets.py b/django/newforms/extras/widgets.py
a
|
b
|
class SelectDateWidget(Widget):
|
31 | 31 | self.years = range(this_year, this_year+10) |
32 | 32 | |
33 | 33 | def render(self, name, value, attrs=None): |
34 | | try: |
| 34 | if isinstance(value, basestring): |
35 | 35 | value = datetime.date(*map(int, value.split('-'))) |
36 | | year_val, month_val, day_val = value.year, value.month, value.day |
37 | | except (AttributeError, TypeError, ValueError): |
38 | | year_val = month_val = day_val = None |
| 36 | year_val, month_val, day_val = value.year, value.month, value.day |
39 | 37 | |
40 | 38 | output = [] |
41 | 39 | |