Hello,
Based on this thread:
http://groups.google.com/group/django-users/browse_thread/thread/fd450734295e450f/68d466b0d6b24eb7
I have the following code for the SplitDateWidget:
class SplitDateWidget(forms.MultiWidget):
def __init__(self, attrs=None):
widgets = (Select(attrs=attrs, choices=DAY_LIST),
Select(attrs=attrs, choices=MONTH_LIST), Select(attrs=attrs,
choices=YEAR_LIST))
super(SplitDateWidget, self).__init__(widgets, attrs)
def value_from_datadict(self, data, files, name):
return [widget.value_from_datadict(data, files, name + '_
%s' % i) for i, widget in enumerate(self.widgets)]
def decompress(self, value):
if value:
print 'value: ', value
value=unicode(value).split('-')
return [value[2],value[1],value[0]]
return None
And I don't know what do I need to change in value_from_datadict to
get this work after request.POST. As for now I get error: "Ensure this
value has at most 3 characters (it has 22)."